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
TestCaféでE2Eテスト!
Search
Azusa Okamoto
May 28, 2022
Programming
160
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TestCaféでE2Eテスト!
Azusa Okamoto
May 28, 2022
More Decks by Azusa Okamoto
See All by Azusa Okamoto
GraphQLでAPI開発 やってみよう!
azunyan
0
40
「わたし色」の見方で拓く世界
azunyan
0
29
ちゃんとSvelte, Hello Worldした!
azunyan
0
77
最近取り組んでいることについて喋ってみる
azunyan
0
24
フロントエンドエンジニアが関数型プログラミングに出会った話
azunyan
0
120
TECH WOMAN KANSAIの 取り組みと今後~2024年の振り返りと2025年へ~
azunyan
0
100
Go初心者が開発やってみた!
azunyan
1
580
デブサミウーマン2023 アウトプットって何が良いの?
azunyan
0
1.3k
個人的に楽しかった実装2022
azunyan
0
150
Other Decks in Programming
See All in Programming
AI時代に設計が 最大の生産性レバーになる 意図駆動開発とデータを消さない設計|Don't Delete Your Data or Your Intent — Design as the Deepest Lever in the AI Era
tomohisa
1
760
React本体のコードリーディング
high_g_engineer
1
140
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
100
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
310
改善しないと、タスクが回らない。 “てんこ盛りポジション” を引き継いだ情シスの、入社3ヶ月の業務改善録
krm963
0
260
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
310
FDEが実現するAI駆動経営の現在地
gonta
2
280
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
370
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
670
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
560
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
130
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
220
Featured
See All Featured
The untapped power of vector embeddings
frankvandijk
2
1.8k
Navigating Team Friction
lara
192
16k
Claude Code のすすめ
schroneko
67
230k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Done Done
chrislema
186
16k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
740
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
119
120k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
470
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
The Language of Interfaces
destraynor
162
27k
Transcript
TestCaféでE2Eテスト! あずにゃん 20220528_とにかくほめる!マウントなしのLT会
自己紹介 ・フロントエンドエンジニア ・気づけば、2年目... 【言語】 JavaScript, TypeScript 【FW・ライブラリ】 React, Vue.js @azunyan_eng
今日お話しすること 1. E2Eテストとは? 2. TestCaféとは? 3. 主な使い方 4. 実践! 5.
感想や学び 6. 参考資料
1. E2Eテストとは? 2. TestCaféとは? 3. 主な使い方 4. 実践! 5. 感想や学び
6. 参考資料
E2Eテストとは? システム全体をテストする。 ユーザが利用する時のように、ブラウザ操作をしながら テスト。
1. E2Eテストとは? 3. 主な使い方 4. 実践! 5. 感想や学び 6. 参考資料
2. TestCaféとは?
TestCaféとは? ・E2Eテスト自動化フレームワーク。 ・JavaScript/TypeScriptで記述。 ・複数のブラウザに対応 ・複数のブラウザで同時実行できる。
TestCaféとは? const const homeTab = ( ). ( ). (
); = . ( ). ( ); . ( . ). ( ); tabs homeTab tabs Selector find nth child nth expect eql '#root' 'div' 'a' 'Home' 2 0 awaitt innerText (例)
手動でポチポチ...。 手動の操作不要! TestCaféなし TestCaféあり
1. E2Eテストとは? 2. TestCaféとは? 4. 実践! 5. 感想や学び 6. 参考資料
3. 主な使い方
主な使い方 ①要素関係(取り出してくるなど...) ②テスト関係
innerText value 要素のテキストを取得。 input要素のテキストを 取得。
(例) // innerText // value const const = . (
). ; = . ( ). ; pageTitle pageContents inputForm form $ formName child find 'h1' `input[name=" "]` innerText value { }
getStyleProperty() 要素が持つ、指定したCSSのプロパティの値を取得。
(例) // 背景色を取ってくる。 const = . ( ); activeBG homeTab
getStyleProperty 'background-color'
hasAttribute() その要素が指定した属性を持っているかどうかを返す。
(例) const = . ( ); btnWithDisabled submitBtn hasAttribute 'disabled'
click() 要素をクリックする。
click() (例) const const = ( ). ( ). (
); = . ( ). ( ); . ( ); navTabs formTab navTabs formTab Selector find nth child nth click '#root' 'div' 'a' 2 1 await t
typeText() テキストを入力する。
click() (例) const true . await inputForm form inputForm =
( ); find typeText `input[name="name"]` 'テスト花子' . ( , , : ); t { } replace
eql() notEql() 値が合っているか。 値が異なっているか。
click() (例) // クラス名で指定することも可能 // await t.expect(対象要素).eql(想定している結果); const const =
( ). ( ); = . ( ). ; . ( ). ( ); modal modalText modal modalText Selector child child expect eql '.test-modal' 'div' 'p' 'Modalが出現!!' innerText t await
ok() notOk() 値がtrueであるか。 値がfalseであるか。
click() (例) // ok() // notOk() await await . (
. ( )). (); . ( . ( )). (); t t expect hasAttribute ok expect hasAttribute notOk submitBtn submitBtn 'disabled' 'disabled'
takeScreenshot() スクリーンショットを撮影。 指定したパスに保存される。
click() (例) await . ( : , : ); t
takeScreenshot { 'result/checkHomeTabContents.png' } path fullPage true
1. E2Eテストとは? 2. TestCaféとは? 3. 主な使い方 5. 感想や学び 6. 参考資料
4. 実践!
実践! 表示されている内容や要素が持つ属性などを利用して、 テストしていく!
実践! 〜主なテスト内容〜 ・Homeタブが表示されているか。
実践! 〜主なテスト内容〜 ・Formタブが表示されているか。 ・初期状態で、送信ボタンが無効になっているか。 ・初期値が合っているか。 ・フォームに入力できるか。 ・フォーム入力後、送信ボタンが有効になっているか。
実践! 〜主なテスト内容〜 ・Buttonsタブが表示されているか。 ・モーダルが表示されるか。 ・モーダルを消すことができるか。
動かしてみる!!
1. E2Eテストとは? 2. TestCaféとは? 3. 主な使い方 4. 実践! 6. 参考資料
5. 感想や学び
感想や学び ・「現状」だけでなく、「今後」のことも考慮して要素 を指定! ・色関係や改行ありテキスト判定において、制約がある のになかなか気がつけずて手間取った。 ・画面仕様をじっくり見る機会になり、プロジェクトに 途中から参画しても仕様把握に繋がって助かった!
感想や学び ・コマンドを実行すると、ブラウザが立ち上がって、自 動でテストできるのは便利! ・テストコード作成初心者でも、メソッドを組み合わせ ていくことで問題なく扱えた!
1. E2Eテストとは? 2. TestCaféとは? 3. 主な使い方 4. 実践! 5. 感想や学び
6. 参考資料
参考資料 TestCafé公式ドキュメント
ご清聴ありがとう ございました!