Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PlaywrightによるSvelteコンポーネントテスト
Search
kubotak
October 27, 2022
Programming
0
3.6k
PlaywrightによるSvelteコンポーネントテスト
Nextbeat Tech Bar:SvelteKit導入企業2社による本音LT会
kubotak
October 27, 2022
Tweet
Share
More Decks by kubotak
See All by kubotak
情報漏洩させないための設計
kubotak
0
83
Svelteコンポーネントの依存関係に秩序を〜
kubotak
0
74
DMARCレポート可視化ツールを SvelteKitで作った話
kubotak
2
460
Superforms本番投入で分かった良さとハマりどころ
kubotak
0
680
Storybookを書くだけでリグレッションテストが 実行される世界へようこそ
kubotak
31
10k
(うまくいった||いかなかった) 技術選定は何を考えていたか
kubotak
1
1.1k
ウォーターフォールに思えたプロジェクトにあったアジャイルの要素
kubotak
2
710
Felteで作る簡単フォームバリデーション
kubotak
1
1.4k
SvelteKitを本番投入してみて
kubotak
2
1.9k
Other Decks in Programming
See All in Programming
Symfony Mapper Component
soyuka
2
730
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
740
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
770
103 Early Hints
sugi_0000
1
230
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
200
Zoneless Testing
rainerhahnekamp
0
120
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
140
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
310
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
1
370
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
460
命名をリントする
chiroruxx
1
400
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
4 Signs Your Business is Dying
shpigford
181
21k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
Embracing the Ebb and Flow
colly
84
4.5k
The Cost Of JavaScript in 2023
addyosmani
45
7k
Scaling GitHub
holman
458
140k
Code Reviewing Like a Champion
maltzj
520
39k
Agile that works and the tools we love
rasmusluckow
328
21k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Music & Morning Musume
bryan
46
6.2k
Transcript
Copyright© M&AΫϥυ PlaywrightʹΑΔ Svelteίϯϙʔωϯτςετ Nextbeat Tech BarɿSvelteKitಋೖاۀ2ࣾʹΑΔຊԻLTձ / Kenjiro Kubota
Copyright© M&AΫϥυ index • SvelteKitͰͷίϯϙʔωϯτͷ࡞Γํ • PlaywrightʹΑΔίϯϙʔωϯτͷςετ ࠓ͢͜ͱ • SvelteɺSvelteKitͷৄࡉ༷
• SvelteKitΛ࠾༻ͨ͠ ࠓ͞ͳ͍͜ͱ
Copyright© M&AΫϥυ SvelteKitಋೖʹؔͯ͠ͷϑϩϯτΤϯυΧϯϑΝϨϯεԭೄ2022 Ͱ͓͠·͢ɻ
Copyright© M&AΫϥυ Profile ٱอా ݡೋ࿕ kubotak-is kubotak_public kenjiro.kubota גࣜձࣾM&AΫϥυॴଐ TypeScript
PHP https://kubotak.page ϓϩϑΣογϣφϧWebϓϩάϥϛϯά Laravel (ڞஶ) Ѫݘɿ౾ࣲ
Copyright© M&AΫϥυ ٻਓࠂαΠτͷΑ͏ͳM&AμΠϨΫτϚονϯά 5 ങ͍ख ɾҊ݅ใुM&AޭใुͷΈ ɾ࠷खྉͳ͠ ɾചΓखιʔγϯάͷνϟωϧ͕૿͑Δ ɾM&AχʔζΛൃ৴͢Δ͚ͩͰചΓखΛू٬ ɾհۀऀΛհͣ͞ʹμΠϨΫτʹΓऔΓՄೳ
ɾજࡏʹϦʔν͕Մೳ खྉແ ྉ ※ϓϥοτϑΥʔϜҊ݅ͷ߹ ※ ചΓख 1.ܝࡌ͢Δ ɾങ͍खͷM&AχʔζΛࣗΒௐΔ͜ͱ͕Մೳ ɾհۀऀΛհͣ͞ʹμΠϨΫτʹΓऔΓՄೳ ɾങ͍खͷM&A୲ऀʹίϯλΫτΛͱΕΔ ɾհۀऀΛΘͳ͍ͷͰखྉ͕ແྉ 2.ΦϑΝʔ͢Δ M&Aɾग़ࢿχʔζΛܝࡌ ങ͍खͷϝϦοτ ചΓखͷϝϦοτ ɾհۀऀΛΘͳ͍ͷͰखྉ͕ແྉ ʓʓྖҬͷձࣾΛ ืू͠·͢ ͜ͷձࣾͱҰॹʹ ͍͖͍ͬͯͨʂ 5 PR
Copyright© M&AΫϥυ Svelteͱʁ Svelte • Write less code ◦ গͳ͍هड़
• No virtual DOM ◦ Ϗϧυ࣌ʹVanilla JSʹίϯύΠϧ • Truly reactive ◦ એݴతͳ state ۦಈܕͷίʔυΛॻ͘ඞཁ͕ͳ͍ ReactVue.jsʹྨ͢ΔUIߏஙͷͨΊͷίϯϙʔωϯτϑϨʔϜϫʔΫ feature
Copyright© M&AΫϥυ SvelteKitͱʁ SvelteKit SvelteΛϕʔεͱͨ͠WebΞϓϦέʔγϣϯΛߏங͢ΔͨΊͷϑϨʔϜϫʔΫ • Next.js (React) • Nuxt
(Vue.js) Similar ※SvelteKitSvelteͱಉ͡ίϛϡχςΟ͕ཧ͍ͯ͠ΔͰ্هͱҟͳΔ
Copyright© M&AΫϥυ ࠃࣄྫ ͡Ό͕Γ͜ͷಛઃαΠτ͕SvelteKitͰ࡞ΒΕͯΔΈ͍ͨͰ͢ʂ https://www.calbee.co.jp/agerico/jagaricocomic/
Copyright© M&AΫϥυ SvelteKitͷجຊతͳσΟϨΫτϦߏ
Copyright© M&AΫϥυ SvelteKitͷجຊతͳσΟϨΫτϦߏ ΞϓϦέʔγϣϯͷίʔυجຊతʹ srcԼʹ࡞͢Δ ※ެࣜखॱͰεέϧτϯΛ࡞ͨ͠ޙͷσΟϨΫτϦ
Copyright© M&AΫϥυ SvelteKitͷجຊతͳσΟϨΫτϦߏ ϧʔςΟϯάϑΝΠϧγεςϜϕʔε ※ϧʔϧಛघͳͨΊৄ͘͠υΩϡϝϯτΛࢀর͍ͩ͘͞ ※ެࣜखॱͰεέϧτϯΛ࡞ͨ͠ޙͷσΟϨΫτϦ
Copyright© M&AΫϥυ SvelteKitͷجຊతͳσΟϨΫτϦߏ ࡞࣌ʹҎԼΛબ͢ΔͱPlaywrightʹ ΑΔςετ͕ॳظಋೖ͞ΕΔ ✔ Add Playwright for browser
testing? … No / Yes ※Playwrightʹ͍ͭͯޙͰ͓͠·͢ ※ެࣜखॱͰεέϧτϯΛ࡞ͨ͠ޙͷσΟϨΫτϦ
Copyright© M&AΫϥυ 🤔ίϯϙʔωϯτͲ͜ʁ
Copyright© M&AΫϥυ src/libʹ$libΤΠϦΞε͕ுΒΕ͍ͯͯɺίϯϙʔωϯτ͜ͷதʹஔ͘ ͷ͕SvelteKitྲྀͬΆ͍ ※ެࣜυΩϡϝϯτΑΓ
Copyright© M&AΫϥυ ͬͯΈΑ͏🚀
Copyright© M&AΫϥυ srcσΟϨΫτϦԼʹlib/componentsΛ࡞
Copyright© M&AΫϥυ routes/+page.svelte͔ΒίϯϙʔωϯτΛݺͼग़͠
Copyright© M&AΫϥυ routes/+page.svelte͔ΒίϯϙʔωϯτΛݺͼग़͠ $libΤΠϦΞε Ͱݺͼग़͠
Copyright© M&AΫϥυ ϒϥβͰݟΔͱ͜Μͳײ͡👍
Copyright© M&AΫϥυ ίϯϙʔωϯτͷςετ
Copyright© M&AΫϥυ ίϯϙʔωϯτͷςετ M&AΫϥυͰҎԼͷ2ͭͷςετΛ࣮ࢪ • Playwright ◦ ίϯϙʔωϯτͷϦάϨογϣϯςετ • Vitest
◦ APIͷmock͕ඞཁͳςετ
Copyright© M&AΫϥυ ίϯϙʔωϯτͷςετ M&AΫϥυͰҎԼͷ2ͭͷςετΛ࣮ࢪ • Playwright ◦ ίϯϙʔωϯτͷϦάϨογϣϯςετ • Vitest
◦ APIͷmock͕ඞཁͳςετ ࠓͪ͜Βʹ͍ͭͯհ
Copyright© M&AΫϥυ Playwright CypressPuppeteerͷΑ͏ʹNode.jsͰE2Eςετ͕࣮ߦͰ͖ΔϥΠϒϥϦ • MicrosoftͷOSSʢݩPuppeteerνʔϜʣ • Chromium,firefox,webkitʹΑΔΫϩεϒϥβͷςε τ͕Մೳ •
ࢼݧత͕ͩɺίϯϙʔωϯτͷςετٴͼɺϏδϡΞϧ ϦάϨογϣϯςετՄೳ feature
Copyright© M&AΫϥυ Playwright CypressPuppeteerͷΑ͏ʹNode.jsͰE2Eςετ͕࣮ߦͰ͖ΔϥΠϒϥϦ • MicrosoftͷOSSʢݩPuppeteerνʔϜʣ • Chromium,firefox,webkitʹΑΔΫϩεϒϥβͷςε τ͕Մೳ •
ࢼݧత͕ͩɺίϯϙʔωϯτͷςετٴͼɺϏδϡΞϧ ϦάϨογϣϯςετՄೳ feature ࠓͪ͜Βʹ͍ͭͯհ
Copyright© M&AΫϥυ ͬͯΈΑ͏🚀
Copyright© M&AΫϥυ ίϯϙʔωϯτςετ༻ͷґଘͱઃఆΛಋೖ ϑϨʔϜϫʔΫબʹSvelte͕͋Δʂ
Copyright© M&AΫϥυ ίϚϯυΛ࣮ߦ͢ΔͱҎԼ͕มߋ͞ΕΔ • @playwright/experimental-ct-svelte͕Πϯετʔϧ͞ΕΔ • npm scriptsʹtest-ctίϚϯυ͕Ճ͞ΕΔ • ϓϩδΣΫτϧʔτʹplaywright/index.html͕࡞͞ΕΔ
• ϓϩδΣΫτϧʔτʹplaywright-ct.config.ts͕࡞͞ΕΔ
Copyright© M&AΫϥυ ઌఔ࡞ͨ͠ίϯϙʔωϯτΛςετ tests/Test.spec.ts
Copyright© M&AΫϥυ $libͷΤΠϦΞεύε͕ղܾͰ͖ͳ͍ͷͰplaywright-ct.config.tsʹҎ ԼΛՃ
Copyright© M&AΫϥυ npm run test-ctΛ࣮ߦ͢Δ ※ॳճ࣮ߦ֤࣌ϒϥβͷμϯϩʔυ͕࣮ߦ͞ΕΔ
Copyright© M&AΫϥυ npm run test-ctΛ࣮ߦ͢Δ ※ॳճ࣮ߦ֤࣌ϒϥβͷμϯϩʔυ͕࣮ߦ͞ΕΔ 3ϒϥβͰςετ͍ͯ͠ΔͷͰ 3passedʹͳΔ
Copyright© M&AΫϥυ npx playwright show-reportΛ࣮ߦ͢ΔͱϨϙʔτ͕ݟΕΔ
Copyright© M&AΫϥυ ϏδϡΞϧϦάϨογϣϯςετͬͯΈΑ͏🎭
Copyright© M&AΫϥυ ίϯϙʔωϯτ͕εΫϦʔϯγϣοτͱҰக͢Δ͜ͱΛςετ͢Δ
Copyright© M&AΫϥυ npm scriptsʹεΫϦʔϯγϣοτऔಘίϚϯυΛՃ ࣮ߦ͢ΔͱεΫϦʔϯγϣοτ͕ग़ྗ͞ΕΔ
Copyright© M&AΫϥυ σϑΥϧτͰϧʔτσΟϨΫτϦ͔Β__snapshots__σΟϨΫτϦ ʹεΫϦʔϯγϣοτ͕อଘ͞ΕΔ ͜ͷεΫϦʔϯγϣοτͱςετ࣌ʹҰக͢Δ͔ΛνΣοΫ͢Δɻ ίϯϙʔωϯτʹ͕ࠩ͋ΔͱςετࣦഊʹͳΔ
Copyright© M&AΫϥυ εΫϦʔϯγϣοτʹΑΔϦάϨογϣϯςετ͕ࣦഊͨ͠߹
Copyright© M&AΫϥυ εΫϦʔϯγϣοτʹΑΔϦάϨογϣϯςετ͕ࣦഊͨ͠߹ ςετର͕ڱ͍ͷͰςΩετϨϕϧ ͷςετͰ௨աͯ͠͠·͏
Copyright© M&AΫϥυ ActualͰࣦഊΛ֬ೝ͢Δ͜ͱ͕Ͱ͖Δ
Copyright© M&AΫϥυ ͕ࠩখ͍͞߹DiffͰࡉ͔֬͘ೝͰ͖Δ
Copyright© M&AΫϥυ 🚀 Pros • ࢼݧతͰ͋Δ͕ेར༻Ͱ͖Δ • PR࣌ʹίϯϙʔωϯτͷεΫϦʔϯγϣοτ͕͋ΔͱϨϏϡʔ͠ ͍͢ •
ΫϩεϒϥβͰεΫϦʔϯγϣοτ͕ࡱΒΕΔͷͰಛఆͷϒϥ β่Εʹࣄલʹؾͮ͘͜ͱ͕Ͱ͖Δ • ςΩετϨϕϧͷςετʹൺͯεΫγϣςετίϯϙʔωϯ τશମΛ୲อͰ͖Δ
Copyright© M&AΫϥυ 🫠 Cons • jsdomʹΑΔςετʹൺΔͱ࣮ߦ͕͔͔࣌ؒΔ • ϦϙδτϦʹը૾Λͦͷ··ஔ͍͍ͯΔͷͰকདྷతͳ༰ྔ͕ؾʹ ͳΔ •
CIͰ࣮ߦ͢Δ߹ɺࣄલʹϒϥβ͕Πϯετʔϧ͞ΕͨDocker ΠϝʔδΛϗεςΟϯά͓ͯ͘͠ͳͲޮΑ͘͏ͨΊʹҰखؒ ඞཁ
Copyright© M&AΫϥυ Thanks for watching this :)