0
0

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で特定のテストスイートのみを実行する : only

Last updated at Posted at 2025-01-11

まとめ

Vitestで特定のテストスイートのみコードベースから変更して動作させたい場合は、 onlyを利用しましょう。

import { assert, test } from 'vitest'

test.only('test', () => {
  assert.equal(Math.sqrt(4), 2)
})

ちなみに、describe.onlyというのもあります。

特定のファイルを実行したときだけ動作します。

vitest 〇〇.test.ts

only を知るまで

適当なテストスイートに、skipを付けたり、コメントアウトしたりしていました。

他に VS Code の Vitest のプラグインのデバッグで特定のテストケースだけ動作させるとかしていました。

さらに cli の testNamePattern とかも利用していました。

今まで何だったんだろう。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?