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
再実装 React Testing Library
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Ryusou
December 07, 2022
Programming
240
0
Share
再実装 React Testing Library
Saitama.js vol.4でのLTです。
React Testing Libraryのassert関数を少しだけ自作してみました。
Ryusou
December 07, 2022
More Decks by Ryusou
See All by Ryusou
Astro 3.0入門
nozaki
0
480
Hydrogenで 2022年〜を感じる
nozaki
0
650
microCMSでimgixに入門する
nozaki
0
1.2k
Jamstack Conf 2021を見てブログ構成を見直した話
nozaki
1
1.4k
ユーザーが編集中の状態管理について考えよう
nozaki
3
7.1k
はじめてのUniversal JavaScript
nozaki
1
2.6k
Other Decks in Programming
See All in Programming
ポーリング処理廃止によるイベント駆動アーキテクチャへの移行
seitarof
3
1.3k
最初からAWS CDKで技術検証してもいいんじゃない?
akihisaikeda
4
180
おれのAgentic Coding 2026/03
tsukasagr
1
130
Kubernetes上でAgentを動かすための最新動向と押さえるべき概念まとめ
sotamaki0421
2
380
モックわからないマン卒業記 ~振る舞いを起点に見直した、フロントエンドテストにおけるモックの使いどころ~
tasukuwatanabe
3
440
見せてもらおうか、 OpenSearchの性能とやらを!
shunta27
1
170
GoのDB アクセスにおける 「型安全」と「柔軟性」の両立 - Bob という選択肢
tak848
0
310
Laravel Nightwatchの裏側 - Laravel公式Observabilityツールを支える設計と実装
avosalmon
1
310
へんな働き方
yusukebe
6
2.9k
「速くなった気がする」をデータで疑う
senleaf24
0
130
条件判定に名前、つけてますか? #phperkaigi #c
77web
2
940
事業会社でのセキュリティ長期インターンについて
masachikaura
0
230
Featured
See All Featured
Navigating Weather and Climate Data
rabernat
0
160
The agentic SEO stack - context over prompts
schlessera
0
730
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
170
Between Models and Reality
mayunak
3
260
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Embracing the Ebb and Flow
colly
88
5k
Everyday Curiosity
cassininazir
0
190
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
110
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
220
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
30 Presentation Tips
portentint
PRO
1
270
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
170
Transcript
しばらくお待ちください
私について りゅーそう 埼玉県育ちのエンジニアです。 (生まれは千葉なのは内緒...) Saitama.jsの運営しています。 埼玉のおすすめ観光地は権現堂の桜 です
I LOVE 杉戸町 「杉戸天然温泉 雅楽の湯」は日本一 の温泉といっても過言ではない 食事は「高橋屋」で鰻コースを予約 して優勝です。 お子様連れは東武動物公園もあるよ (隣の宮代町だけど...)
画像:https://utanoyu.com/より
ありがとうございました! (今日はこれを伝えにきました)
サンプルのクソアプリ
フォームの(一部の) テストをやっていきます
再実装 React Testing Library
React Testing Library Reactコンポーネントのテストライブラリ https://testing-library.com/docs/react-testing-library/example-intro
None
ASSERTを自作していく💪 https://testing-library.com/docs/react-testing-library/example-intro
再実装 React Testing Library ASSERT編
DEMO InputWithAlert コンポーネント
STEP1:idを使ったテスト
STEP1:idを使ったテスト getByIdを作成する ・idは一意ではならない ・本来は必要のないマークアップ ・テスト書きながら、プロダクト独自 の値を参照するのがとても辛い
STEP2:roleを使ったテスト queryByRoleをつくる ・マークアップも改善する ・id管理がなくなるなど壊れにくいテス トになる ・(ロールの知識があれば)暗黙的にテ ストが書ける
STEP3: a11ty assertion aria-invalidをテストします
STEP3: a11ty assertion a11tyを関数でテスト ・マークアップがa11tyを満たしているかを関 数側で担保できる ・ まとめておくことで一連のinterfation test 的なのが書きやすい(はず...未検証.....)
・Headless UIが行っている
STEP3: a11ty assertion before after -----act----- https://github.dev/tailwindlabs/headlessui
TEST ALL PASS!! LGTM👏👏
None
ライブラリを適切に 使っていこう!
参考 「雅楽の湯公式サイト」 https://utanoyu.com/ 「React Testing Library」 https://testing-library.com 「Headless UI GitHub」
https://github.dev/tailwindlabs/headlessui 「Headless UI」 https://headlessui.com 「React Hook Form」 https://react-hook-form.com/advanced-usage/
おしまい