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
200
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
100
作成中のFlutterアプリの中間発表
wheatandcat
0
86
最近読んだ技術書を簡単紹介
wheatandcat
0
110
ユニバーサルリンク/アプリリンクを使ってQRコードでゲストログインできるようにする
wheatandcat
0
380
Firebase App Checkを実装したので紹介
wheatandcat
0
310
PlanetScaleの無料プランがなくなるので、NeonとTiDBを試してみた
wheatandcat
0
410
Flutter HooksとRiverpodの解説
wheatandcat
0
580
T3 Stack(応用編: Next Auth & SSRの実装紹介)
wheatandcat
1
400
App Routerの紹介
wheatandcat
0
150
Other Decks in Programming
See All in Programming
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
780
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
150
Contextとはなにか
chiroruxx
1
390
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
240
スマートグラスで並列バイブコーディング
hyshu
0
270
LaravelLive Japan の裏方のすべて — 第188回 PHP勉強会@東京 (2026-06-24)
suguruooki
2
140
AI時代のUIはどこへ行く?その2!
yusukebe
22
7.7k
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.6k
Performance Engineering for Everyone
elenatanasoiu
0
250
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
320
20260623_Loop Engineeringで自分の分身の問い合わせBotを作る
ryugen04
0
110
ローカルLLMでどこまでコードが書けるか -縮小版 / How much code can be written on a local LLM Shortened
kishida
2
170
Featured
See All Featured
Designing Experiences People Love
moore
143
24k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
230
The agentic SEO stack - context over prompts
schlessera
0
840
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
380
YesSQL, Process and Tooling at Scale
rocio
174
15k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Statistics for Hackers
jakevdp
799
230k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
220
Site-Speed That Sticks
csswizardry
13
1.2k
Designing Powerful Visuals for Engaging Learning
tmiket
1
430
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
300
Typedesign – Prime Four
hannesfritz
42
3.1k
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 移行が進んでいるので、合わせてテストフレームワークも移行を検討すると良い かなと思います。
ご清聴ありがとうございました