$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
JestとWallaby.jsで始める楽しいJavaScript testing
Search
Shunta Saito
June 26, 2019
Programming
2
1.4k
JestとWallaby.jsで始める楽しいJavaScript testing
JestとWallaby.jsを使ってモックを含むテストを書く方法を共有します。
https://github.com/subuta/play-with-jest
Shunta Saito
June 26, 2019
Tweet
Share
More Decks by Shunta Saito
See All by Shunta Saito
Nuxt.jsの静的サイト 出力を試してみる
subuta
0
500
Wordpress + ACF(Pro) Blocksで 独自コンポーネントを作る
subuta
0
290
Tailwind CSSでいろんなUIをつくる
subuta
3
1.1k
SPA & JWT でWeb アプリケーションを作る
subuta
0
200
jspmで爆速開発する
subuta
1
1.3k
Other Decks in Programming
See All in Programming
Missing parts when designing and implementing Android UI
ericksli
0
390
Reckoner における Datadog Browser Test の活用事例 / Datadog Browser Test at Reckoner
nomadblacky
0
190
Develop iOS apps with Neovim / vimconf_2024
uhooi
1
300
[FlutterKaigi2024] Effective Form 〜Flutterによる複雑なフォーム開発の実践〜
chocoyama
1
3.9k
5分ぐらいで分かる、トリミング機能の作り方
tsutsuitakumi
0
190
Serverless苦闘史
mosh_inc
0
140
アニメーションを最深まで理解してパフォーマンスを向上させる
mine2424
0
100
42 best practices for Symfony, a decade later
tucksaun
1
110
TypeScript でバックもやるって実際どう? 実運用で困ったこと3選
yuichiro_serita
17
7.6k
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
150
As an Engineers, let's build the CRM system via LINE Official Account 2.0
clonn
1
640
The rollercoaster of releasing an Android, iOS, and macOS app with Kotlin Multiplatform | droidcon Italy
prof18
0
130
Featured
See All Featured
Designing for Performance
lara
604
68k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Designing Experiences People Love
moore
138
23k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Navigating Team Friction
lara
183
15k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
890
Gamification - CAS2011
davidbonilla
80
5.1k
Producing Creativity
orderedlist
PRO
341
39k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Embracing the Ebb and Flow
colly
84
4.5k
Scaling GitHub
holman
458
140k
Transcript
JestͱWallaby.jsͰ࢝ΊΔ ָ͍͠JavaScript testing @subuta 2019/6/26
ࣗݾհ • ໊લ: ੪౻ॣଠ (@subuta) • JavaScriptपΓͷͷ͕͖Ͱ ͢ɻ࠷͓ۙࣄͰ Node.js(Koa +
Next.js)Λ͑ͯ ͯϋοϐʔͰ͢ɻ • React͕ओʹ͖Ͱ͕͢ɺVue.js Angular.jsᅂΉఔʹ ৮ͬͯ·͢ɻ༻్ʹԠͨ͡ద ͳͷΛબͿͷ͕ྑͦ͞͏ɻ
Jestͱ Jest is a delightful JavaScript Testing Framework with a
focus on simplicity.
Jestͱ Jest is a delightful JavaScript Testing Framework with a
focus on simplicity. γϯϓϧ͞ʹϑΥʔΧεָ͍ͨ͠͠+BWB4DSJQU 5FTUJOH'SBNFXPSL
Wallaby.jsͱ Wallaby.js runs your JavaScript tests immediately as you type
and displays execution results in your code editor. It also provides beautiful test and code coverage reports updated in realtime.
Wallaby.jsͱ Wallaby.js runs your JavaScript tests immediately as you type
and displays execution results in your code editor. It also provides beautiful test and code coverage reports updated in realtime. 8BMMBCZKT͋ͳͨͷςετίʔυΛλΠϐϯάʹԠ ࣮ͯ͡ߦ͠ɺ࣮ߦ݁ՌΛΤσΟλ্ʹදࣔ͠·͢ɻ ·ͨϦΞϧλΠϜͰͷςετͷ࣮ߦ݁Ռ͓Αͼίʔυ ΧόϨοδͷϨϙʔτදࣔߦ͍·͢ɻ
࣍ w ԿΛςετ͖͔͢ w ςετͷ࣮ྫ
ԿΛςετ͖͔͢ Ͳ͏ͤΔͳΒཏతʹΓ͍ͨ ίʔυΧόϨο δΛʹ͍ͨ͠ ͷͰɺͯ͢ͷςετΛॻ͖ͨ ͍ɾɾ
ԿΛςετ͖͔͢ Ͳ͏ͤΔͳΒཏతʹΓ͍ͨ ίʔυΧόϨοδΛ ʹ͍ͨ͠ ͷͰɺͯ͢ͷςετΛॻ͖͍ͨɾɾ ݱ࣮తʹݫ͍͠ɻ w ͍͍ͩͨͷϓϩδΣΫτͰͦΜͳ༨༟ ࣌ؒ༧ࢉ
ͳ ͍ɻ w ͷ࣭Ͱ࡞Δͷ؆୯͚ͩͲɺΓͷΛΓ͖ Ζ͏ͱ͢Δͱ͕͔͔࣌ؒΔɻ lύϨʔτͷ๏ଇzతͳͭ
ԿΛςετ͖͔͢ ⭕࠷ݶɺඞཁͳͱ͜Ζ͚ͩςετΛॻ͘ɻ
ԿΛςετ͖͔͢ ⭕ྫ͑͜ΜͳςετΛॻ͘ w खͰςετ͢Δͷ͕͍͠ ໘ͳ Օॴ w ྫލ͗ ࠷খ࠷େͷೖྗ w
αʔϏεͷࠜװʹؔΘΔ ॏཁͳ ॲཧ w ྫ͓ۚपΓͷॲཧ ݸਓใʹؔΘΔॲཧ
ԿΛςετ͖͔͢ ❌ٯʹ͜Μͳςετෆཁ ˞ݸਓͷҙݟͰ͢ w ϥΠϒϥϦͷڍಈ w ͦͦϥΠϒϥϦଆͰςετΛॻ͍ͯΔͣɻ w 6*ͷςετ
w ߹ ϓϩμΫτͷੑ࣭ɺ։ൃن ʹΑΔ͕ɺ6* ίϩίϩมΘΔͷͰɺॻ͍ͯແବʹͳΓ͕ͪ
ςετͷ࣮ྫ(σϞ) IUUQTHJUIVCDPNTVCVUBQMBZXJUIKFTU ੫ࠐΈͷஈΛ࣋ͬͨ%#ͷαϯϓϧ w ୯ମςετ w ݁߹ςετ %#࿈ܞ ͔Βͷফඅ੫૿੫
ʹͲ͏ରԠ͢Δ͔ɾɾʹ
ͨ͜͠ͱ w 4JOPO+4ͷVTF'BLF5JNFST ͱ͍͏ͷΛ͏ͱɺ ͷϞοΫ͕Ͱ͖Δɻ˞+FTUʹΈࠐΈͷ VTF'BLF5JNFST ͕͋Δɻ w KFTUGO Λ͏ͱɺؔΛϞοΫͰ͖Δɻ˞Πϕϯ
τϋϯυϥ ྫPO$MJDL ͷςετͱ͔Ͱ͑ͯศར w KFTUNPDL Λ͏ͱɺಛఆͷϞδϡʔϧΛϞοΫ Ͱ͖Δɻ˞@@NPDLT@@σΟϨΫτϦʹϑΝΠϧΛஔ ͘͜ͱͰࣗಈͰϞοΫ͢ΔΈ͋Γ·͢ɻ
Wallaby.jsͷྑ͍ͱ͜Ζ w ςετͷ࣮ߦ݁Ռ͕ɺ࣮ߦՕॴͷۙ͘ʹ ͙͢ʹ ද ࣔ͞ΕΔɻ w ΧόϨοδ͕ΤσΟλ্ʹදࣔ͞ΕΔɻ˞ΧόϨο δࣗମOZDͳͲΛ͑औΕΔɻ w
؆қతͳϕϯνϚʔΫ͍ͯΔ ࣮ߦ͕͍ॲཧΛ ݟ͚͍ͭ͢
ςετͷվળͷࣄྫ →
͓·͚ w KFTUTQZ0O Λ͏ͱɺϝιουݺͼग़͠ΛϞοΫ Ͱ͖Δɻ ϞοΫݩͷݺͼग़͠Λ͙߹ KFTUTQZ0O NPDL*NQMFNFOUBUJPO Λ͏ɻ
w +FTUʹ4OBQTIPU5FTUJOHͱ͍͏6*ͷςετ͚ʹ ར༻Ͱ͖Δػೳ͕͋Γ·͢ɻ w &&ςετ ϒϥβʹΑΔࣗಈςετ Λߦ͏߹ɺ $ZQSFTTͱ͍͏πʔϧ͋Γ·͢ɻ Կ͔Χοί͍͍ ͭ
͝੩ௌ͋Γ͕ͱ͏͟͝ ͍·ͨ͠