編集

Vitest 3.2 リリース

Vitest 3.2 がリリース。Browser Mode と TypeScript サポートの改善に焦点を当て、新しいメソッドや設定オプションを追加。workspace設定が非推奨となり、代わりにprojectsオプションの使用を推奨。

typescript
import { defineConfig } from "vitest/config";
export default defineConfig({
  test: {
    projects: [{ test: { name: "Unit" } }, { test: { name: "Integration" } }],
  },
});

主な新機能として、テストにカスタムメッセージや添付ファイルを追加できるAnnotation APItest.extendフィクスチャのスコープ指定(fileまたはworker)、プロジェクト名のカスタムカラー設定、カスタムブラウザロケーター API の追加など。

typescript
test("hello world", async ({ annotate }) => {
  // テストにアノテーションを付与できる
  await annotate("this is my test");

  if (condition) {
    await annotate("this should've errored", "error");
  }

  const file = createTestSpecificFile();
  await annotate("creates a file", { body: file });
});

出展:Vitest 3.2

編集