Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
再実装 React Testing Library
Search
Ryusou
December 07, 2022
Programming
270
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
再実装 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
510
Hydrogenで 2022年〜を感じる
nozaki
0
680
microCMSでimgixに入門する
nozaki
0
1.2k
Jamstack Conf 2021を見てブログ構成を見直した話
nozaki
1
1.4k
ユーザーが編集中の状態管理について考えよう
nozaki
3
7.2k
はじめてのUniversal JavaScript
nozaki
1
2.8k
Other Decks in Programming
See All in Programming
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
1
240
Spec-driven Development with AI
simas
PRO
0
2.2k
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
110
GraphQL の onError と Nullability のこれから
quramy
0
200
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
1
1.9k
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
300
最近”作らせてる” ローカルAIアプリの話
akit37
0
530
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
120
高橋メソッドでCVE解説シリーズ 〜CVE-2026-112816〜
hakkadaikon
0
170
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
4
3.5k
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
210
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
0
110
Featured
See All Featured
A Soul's Torment
seathinner
8
3.9k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
So, you think you're a good person
axbom
PRO
2
2.2k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
310
Building the Perfect Custom Keyboard
takai
2
940
The Mindset for Success: Future Career Progression
greggifford
PRO
0
550
Abbi's Birthday
coloredviolet
4
11k
From π to Pie charts
rasagy
1
430
エンジニアに許された特別な時間の終わり
watany
109
250k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.6k
Technical Leadership for Architectural Decision Making
baasie
3
620
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
660
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/
おしまい