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
0
110
TestCaféでE2Eテスト!
Azusa Okamoto
May 28, 2022
Tweet
Share
More Decks by Azusa Okamoto
See All by Azusa Okamoto
Go初心者が開発やってみた!
azunyan
1
480
デブサミウーマン2023 アウトプットって何が良いの?
azunyan
0
890
TECH WOMAN KANSAIオンラインもくもく会の流れ
azunyan
0
43
個人的に楽しかった実装2022
azunyan
0
92
vanilla-extractを使ってみた!with React
azunyan
1
710
Next.js・microCMSで ポートフォリオサイトを作りかえて学んだこと
azunyan
0
1.9k
VisualStudioCodeの拡張機能を作ってみた!
azunyan
0
36
Other Decks in Programming
See All in Programming
画像でわかる北島直樹
naoki0917
0
110
Quarto Clean Theme
nicetak
0
220
offers_20241022_imakiire.pdf
imakurusu
1
130
2024-10-01 dev2next - Observability for Modern JVM Applications
jonatan_ivanov
1
140
文化が生産性を作る
jimpei
3
630
急速に利用拡大を続ける飲食店向けサービスで 店内端末同士のローカル通信を追加設定なしで実現した話
whatasoda
0
140
空間の中でアイドルとレッスンする技術 - 1st "Vision" / Spatial Lesson technologies with my idol - 1st "Vision"
banjun
PRO
0
250
sqlcを利用してsqlに型付けを
kamiyam
0
250
How to debug Xdebug... or any other weird bug in PHP
dunglas
2
1.5k
個人開発で使ってるやつを紹介する回
yohfee
1
730
Google Play Consoleデベロッパー アカウントの確認 / Verifying your Play Console developer account
kubode
0
310
(Deep|Web) Link support with expo-router
mrtry
0
190
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
41
9.2k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
What's new in Ruby 2.0
geeforr
342
31k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
YesSQL, Process and Tooling at Scale
rocio
167
14k
The Pragmatic Product Professional
lauravandoore
31
6.2k
Testing 201, or: Great Expectations
jmmastey
38
7k
Facilitating Awesome Meetings
lara
49
6k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
260
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Designing on Purpose - Digital PM Summit 2013
jponch
114
6.9k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
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é公式ドキュメント
ご清聴ありがとう ございました!