Skip to content

Vitest 4 にメジャーアップデートする#4744

Open
KentaHizume wants to merge 7 commits intomainfrom
feature/Vitest4へアップグレードする

Hidden character warning

The head ref may contain hidden characters: "feature/Vitest4\u3078\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3059\u308b"
Open

Vitest 4 にメジャーアップデートする#4744
KentaHizume wants to merge 7 commits intomainfrom
feature/Vitest4へアップグレードする

Conversation

@KentaHizume
Copy link
Contributor

@KentaHizume KentaHizume commented Mar 11, 2026

この Pull request で実施したこと

  • 非互換に対応する最小限のスコープで、Vitest 4 にアップグレードしました。
  • ただし、 Dependencies から devDependencies への移動は深刻かつ影響がないので実施しました。(Tree-shakingにより本番コードから参照がないので結局バンドルされていないはず、おそらく airbnb の eslint ルールの何かが抵触して dependencies に移していた)

要確認

  • npm ls vitest を実行し、 vitest 4 系のみが使用されていること
  • GitHub Actions サマリーのカバレッジ表示が main と見比べて崩れていないこと

この Pull request では実施していないこと

  • Vitest 4 の新機能は別 issue で使用します。
  • AzureADB2CAuth サンプルは現在 CI でカバレッジを取っておらず、かつサポート終了予定なので、カバレッジ系の機能は追加整備しません。

Issues や Discussions 、関連する Web サイトなどへのリンク

なし

@KentaHizume KentaHizume added this to the v2.1.0 milestone Mar 11, 2026
@KentaHizume KentaHizume added the target: Dressca サンプルアプリケーションDresscaに関係がある label Mar 11, 2026
@KentaHizume KentaHizume self-assigned this Mar 11, 2026
@KentaHizume KentaHizume marked this pull request as ready for review March 11, 2026 09:43
Copilot AI review requested due to automatic review settings March 11, 2026 09:43
@KentaHizume KentaHizume linked an issue Mar 11, 2026 that may be closed by this pull request
3 tasks
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Dressca フロントエンド(workspaces: admin / consumer)のユニットテスト基盤を、破壊的変更への対応を最小スコープに抑えつつ Vitest 4 系へアップグレードする PR です。

Changes:

  • admin / consumervitest, @vitest/coverage-v8, @vitest/eslint-plugin を Vitest 4 系へ更新
  • Vitest 設定でテスト除外パターンとカバレッジの include/exclude を調整
  • 依存解決結果として package-lock.json を更新

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
samples/Dressca/dressca-frontend/package-lock.json Vitest 4 反映に伴う lockfile 更新(依存ツリー更新)
samples/Dressca/dressca-frontend/consumer/vitest.config.ts テスト除外と coverage 設定の追加/調整
samples/Dressca/dressca-frontend/consumer/package.json consumer の Vitest 関連依存を 4 系へ更新
samples/Dressca/dressca-frontend/admin/vitest.config.ts テスト除外と coverage 設定の追加/調整
samples/Dressca/dressca-frontend/admin/package.json admin の Vitest 関連依存を 4 系へ更新
Files not reviewed (1)
  • samples/Dressca/dressca-frontend/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

...configDefaults.exclude が含まれます。
[
  '**/node_modules/**',
  '**/dist/**',
  '**/cypress/**',
  '**/.{idea,git,cache,output,temp}/**',
  '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*'
]
root: fileURLToPath(new URL('./', import.meta.url)),
setupFiles: ['./vitest.setup.ts'],
coverage: { provider: 'v8', reporter: ['json-summary', 'html'] },
coverage: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下記のカバレッジの破壊的変更に伴う対応です。
https://vitest.dev/guide/migration.html#v8-code-coverage-major-changes

特記事項として、この影響でカバレッジの各種数値が main と比較して変動しています。
Maia/Maris では OSS 側のデフォルト設定に合わせる方針で対応すべきと判断しています。

実プロジェクトでカバレッジのパーセンテージ等をメトリクスとしている場合は、以前の動作と同じになるように include / exclude の設定をする方針も考えられます。ただし、 2 点目による変動はカバレッジが正確になったことによるものなので、受け入れる必要があります。

  1. coverage.all の削除: v3 ではデフォルトで全ソースファイル(未テストファイル含む)がレポートに含まれていた。v4 ではテスト実行中に読み込まれたファイルのみが含まれる。consumer の total lines が 3406→588 に減ったのはこのため。coverage.include: ['src/**/*.{ts,vue}'] を設定してスコープを明示したが、読み込まれないファイルは含まれない。
  1. V8 カバレッジの AST ベース分析: v3 の v8-to-istanbul から AST ベースに変更され、ブランチ・関数の検出がより正確になった。偽陽性が減った結果、特に branches と functions の数値が変動。

"@vitejs/plugin-vue-jsx": "5.1.2",
"@vitest/coverage-v8": "3.2.4",
"@vitest/eslint-plugin": "1.5.2",
"@vitest/coverage-v8": "4.0.18",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI にカバレッジ分析が入っていない(npm script のみあり)ので、 Dressca 側と異なりレポートの形式を設定する必要がありません。

External ID サンプルには現状あまりテストがないのでカバレッジを使う価値がないのですが、
プロジェクトのテンプレートとしてあったほうがよいと思うので残しました。

@@ -1,5 +1,6 @@
{
"extends": "./tsconfig.app.json",
"include": ["src/**/__tests__/**/*.ts", "env.d.ts"],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

今までは AzureADB2C のテストコードに対して type-check が走っていなかったと思われるので追加しました(とてもまずい)
これまで AzureADB2CのテストコードがDresscaのコピペだったのでバグったソースが入る余地がなく判明していなかったと思われます。

@KentaHizume KentaHizume changed the title Vitest 4 にアップグレード Vitest 4 にアップグレードする Mar 12, 2026
@KentaHizume KentaHizume changed the title Vitest 4 にアップグレードする Vitest 4 にメジャーアップデートする Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

target: Dressca サンプルアプリケーションDresscaに関係がある

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vitest 3系から 4系にメジャーアップデートする

2 participants