0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

VitestとJestの違い -テストコード学習3本目

Posted at

概要

このブログ記事は、テストフレームワークを学ぶ過程で執筆した記事の第2回です。VitestとJestの紹介と簡単な比較を行っています。

Vitestについて

Vitestは、Vite環境向けに最適化されたjavascript,typescript用の高速なユニットテストフレームワークです。ViteとVitestの開発者であるEvan You(Vue.jsの作者)によって2022年に開発されました。

// vitestの基本的なテスト例
import { describe, it, expect } from 'vitest'

describe('基本的な計算', () => {
  it('足し算が正しく動作する', () => {
    expect(1 + 1).toBe(2)
  })
})

Jestについて

Jestはシンプルさを重視したJavaScript用のユニットテストフレームワークです。facebook(meta)によって2012年に開発されました。

//jestの基本的なテスト例
test('足し算が正しく動作する', () => {
  expect(1 + 2 ).toBe(3);
});

VitestとJestの比較

特徴 Vitest Jest
実行速度 非常に高速 比較的遅い(特に起動時間)
設定の一元化 Vite設定と共有・統一可能(vite.config.js) Vite設定と独立した設定が必要(jest.config.js)
スナップショットテスト サポート サポート
ウォッチモード
(ファイルが変更されるたびに自動でテストを再実行する機能)
サポート サポート
カバレッジレポート v8/Istanbul istanbul
APIの互換性 Jest APIと高い互換性あり 独自API
TypeScriptサポート ネイティブサポート 追加設定が必要

参考記事:
https://vitest.dev/guide/coverage

npm trendでの比較

image.png

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?