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
【Vitest5.0大解剖】Vitest5.0で増えた書き方
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
赤神青空
PRO
September 06, 2026
Video
Programming
64
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
【Vitest5.0大解剖】Vitest5.0で増えた書き方
赤神青空
PRO
September 06, 2026
Video
More Decks by 赤神青空
See All by 赤神青空
【AIニュース】OpenAI も Claude も Google Cloud で使える?
akagami
PRO
0
3
【基本情報対策】TCP/IPとOSI参照モデル
akagami
PRO
0
8
AWS Continuum とは何か
akagami
PRO
0
7
【力学 #3】斜方投射を成分に分けて解く
akagami
PRO
0
10
Anthropic の OSS Scanner、AI が脆弱性を探して修正まで出す?
akagami
PRO
0
15
パスキーはなぜフィッシングに強いのか
akagami
PRO
0
26
Claude API の temperature が消えた?
akagami
PRO
0
17
GPT-6.1 Terra とは何か
akagami
PRO
1
43
【力学 #2】空気抵抗のある落下と終端速度
akagami
PRO
0
17
Other Decks in Programming
See All in Programming
ChromeでローカルLLM
ryu1013
0
190
AI Augmentation Techniques with Liberty
ivargrimstad
1
340
TanStack Vue Query と Pinia Colada から学ぶ非同期状態の型設計
aoshi
0
610
小さなアプリを作って公開するまで
onozaty
0
110
Seven New Principles of Software Engineering
yegor256
0
440
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
300
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
140
[DroidKnights 2026] Workflow AX: From Auto-Documented Policies to E2E Testing
raeminkang
0
510
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
340
No More NoSuchMethodError
exoego
1
120
[2026-10-14](C)Re:ゼロから始める異世界生活〜始まりの終わりと終わりの始まり〜
tosite
0
310
AIが実装を担う時代の「技術設計」と「チームマネジメント」
kamina_zzz
1
130
Featured
See All Featured
Become a Pro
speakerdeck
PRO
31
6.3k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.3k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
510
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
Marketing to machines
jonoalderson
1
6k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Tell your own story through comics
letsgokoyo
1
1.1k
Utilizing Notion as your number one productivity tool
mfonobong
4
640
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
460
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
470
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
480
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
380
Transcript
2026年9月 Vitest全5回5.0③ vi.when で増えた書き方 とベンチマーク 赤神 青空
▪mockImplementation vi.whenの中で引数を分岐する必要がなくなった — 引数ごとの振る舞い 引数は深い等価比較で照合され、 expect.any() などの非対称マッチャーも使える。 ts const findById
= vi.fn() vi.when(findById) .calledWith(1) .thenResolve({ id: 1, name: 'Ella' }) .calledWith(2) .thenResolve({ id: 2, name: 'Gracie' }) .calledWith(expect.any(Number)) .thenReject(new Error('not found')) 今ココ API 2/7
▪回数の制御と、消費されたかの検証 vi.when の周辺 、または times オプションで振る舞いの回数を制限できる toHaveBeenExhausted で、登録した振る舞いがすべて消費されたかを検証できる 詳しい使い分けは公式の Conditional
Mocking レシピにまとまっている thenReturnOnce 今ココ API 3/7
▪bench ベンチマークAPIの書き換え はトップレベル import ではなくなった bench はテストコンテキストのフィクスチャになり、通常の test() の中で使う。 ts
test('compare parsers', async ({ bench }) => { const result = await bench.compare( bench('JSON.parse', () => { JSON.parse('{"key":"value"}') }), bench('custom parser', () => { customParse('{"key":"value"}') }), ) expect(result.get('JSON.parse')).toBeFasterThan(result.get('custom parser')) }) 今ココ API 4/7
▪独立した存在から、テストの中の道具へ bench の位置づけが変わった Vitest 系 Vitest . parse.bench.ts parse.bench.ts bench()
※トップレベル import ベンチマークは、テストとは別の存在 出⼒もレポーターとは別扱い テストランナーの機能 ✕ フィクスチャ ✕ ライフサイクルフック ✕ リトライ‧フィルタ ✕ アサーション 使えない test(...) bench ※テストコンテキストの⼀部 テストランナーの機能 ◯ フィクスチャ ◯ ライフサイクルフック ◯ リトライ‧フィルタ ◯ アサーション そのまま使える∕出⼒は default‧json レポーターに含まれる テストコンテキストのフィクスチャになったことで、ランナーの機能が使える 今ココ API 5/7
▪比較と差し替え ベンチマークの周辺 で結果を保存し、 bench.from() でベースラインと比較できる 組み込みのTinybenchを、独自のベンチマークプロバイダに差し替えられる writeResult 今ココ API 6/7
▪ 第3回のまとめ 引数ごとのモックと、テストの中で書くベンチマーク。 vi.when 引数ごとの振る舞いを、分岐を書かずに定義できる。 bench フィクスチャになり、ランナーの機能がそのまま使える。 どちらも既存のテストを壊さない追加です。 今ココ おわりに
7/7