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
Vitestの紹介
Search
Yohei Iino
February 19, 2023
Programming
210
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Vitestの紹介
Vitestの紹介
Yohei Iino
February 19, 2023
More Decks by Yohei Iino
See All by Yohei Iino
1年半放置したExpo製アプリを最新化してみた
wheatandcat
0
110
作成中のFlutterアプリの中間発表
wheatandcat
0
93
最近読んだ技術書を簡単紹介
wheatandcat
0
120
ユニバーサルリンク/アプリリンクを使ってQRコードでゲストログインできるようにする
wheatandcat
0
390
Firebase App Checkを実装したので紹介
wheatandcat
0
330
PlanetScaleの無料プランがなくなるので、NeonとTiDBを試してみた
wheatandcat
0
430
Flutter HooksとRiverpodの解説
wheatandcat
0
590
T3 Stack(応用編: Next Auth & SSRの実装紹介)
wheatandcat
1
410
App Routerの紹介
wheatandcat
0
160
Other Decks in Programming
See All in Programming
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
440
AI時代に設計が 最大の生産性レバーになる 意図駆動開発とデータを消さない設計|Don't Delete Your Data or Your Intent — Design as the Deepest Lever in the AI Era
tomohisa
1
1.1k
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
1
110
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
350
源内ハンズオン概要編
hideg
0
200
Cloudflare is Agents
chimame
0
170
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
120
MySQLとPostgreSQLって何が違うの?
akagami
0
120
プロポーザルを書いてもらう
pvcresin
0
560
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
270
Go 1.27 における memory allocation の高速化
andpad
0
270
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
1
1.9k
Featured
See All Featured
Practical Orchestrator
shlominoach
191
12k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
550
For a Future-Friendly Web
brad_frost
183
10k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
430
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Code Reviewing Like a Champion
maltzj
528
40k
Designing for humans not robots
tammielis
254
26k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
170
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.8k
Transcript
Vitest の紹介 Press Space for next page
自己紹介 📝 飯野陽平(wheatandcat ) 🏢 フリーランスエンジニア(シェアフル株式会社CTO ) 💻 Blog: https://www.wheatandcat.me/
🛠 今までに作ったもの memoir ペペロミア Atomic Design Check List
Vitest とは Vitest はVite 環境で動作する高速なテストフレームワーク 領域的にはJest と同じ 特徴は実行速度の速さ。以下、参考記事 Vitest はどれくらい早いのか
~ Jest と比較 ~ 特にwatch モードが高速 その他にも細かいチューニングがされている
Vitest を導入してみる① 導入は以下を参照。 Getting Started | Guide | Vitest
Vitest を導入してみる② コードは以下みたいな感じで書ける。 import { describe, it, expect } from
'vitest' import { add } from "./calc" describe('suite', () => { it('concurrent test 1', async () => { const r = add(1, 2); expect(r).toEqual(3) }) })
Vitest を導入してみる③ コンポーネントのテストなら以下みたいな感じ。 import { describe, expect, it } from
"vitest"; import { render, screen } from "@testing-library/react"; import Demo from "./Demo"; describe("Demo", () => { it(" タイトルに、「デモ」が表示さてている", () => { const props = { title: " デモ" }; render(<Demo {...props} />); expect(screen.getByText(/ デモ/i)).toBeTruthy(); }); });
Vitest を導入してみる④ テストの実行以下のコマンドでOK 👌。 デフォルトでwatch モードで起動。 $ vitest $ vitest
DEV v0.27.1 ./demo ✓ src/lib/calc.ts (2) ✓ src/components/organisms/Demo.test.tsx (1) Test Files 2 passed (2) Tests 2 passed (2) Start at 23:12:20 Duration 3.25s (transform 1.06s, setup 712ms, collect 725ms, tests 70ms)
カバレッジ/Mocking/Testing Type 以下のあたりはJest とほぼ同様に使用できる。 Coverage Mocking Testing Types
Vitest UI Vitest にUI からテスト実行/ 確認行える機能がある。 Vitest UI 以下のコマンドで実行。 ※
デモで説明。 $ vitest --ui
In-source testing 好みは別れるが、Rust みたいにコード上にテストコードを書くこともできる。 In-source testing | Guide | Vitest
// the implementation export function add(...args: number[]) { return args.reduce((a, b) => a + b, 0) } // in-source test suites if (import.meta.vitest) { const { it, expect } = import.meta.vitest it('add', () => { expect(add()).toBe(0) expect(add(1)).toBe(1) expect(add(1, 2, 3)).toBe(6) }) }
Debugging テストコードでデバッガも使用できる。 Debugging | Guide | Vitest ※ デモで説明。
まとめ Jest 互換なので、移行も比較的に容易に行えるのでおすすめ。 機能もかなり充実しているのでプロダクトで使っても、問題なさ気。 現状だとWebpack →Vite 移行が進んでいるので、合わせてテストフレームワークも移行を検討すると良い かなと思います。
ご清聴ありがとうございました