fix(status): テストファイルをnext buildの型チェック対象から除外 - #226
Conversation
next 16.3以降、`next build` の型チェックが `__tests__` 配下も対象に 含めるようになり、Prismaのモック(`mockResolvedValue`)でTS2339が33件 発生してビルドが失敗する。 テストはvitestが `app/**/__tests__/**` を独自に解決して実行するため、 tsconfigのexcludeに追加してもテスト実行には影響しない。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017fQPt7HiEU36J6ontEjw9h
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Included review availability: 3 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour. 📝 WalkthroughWalkthrough
ChangesstatusアプリのTypeScript設定
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to This localized configuration change excludes test files from the production build type-check while preserving test execution; the reported checks and builds pass, so no actionable merge-blocking risk remains beyond normal review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
背景
#218 (next 16.3.1 へのアップデート) で Vercel の
trainlcd-status-stgビルドが失敗していました。原因は next 16.3 以降、
next buildの型チェックが__tests__配下も対象に含めるようになったことです。app/api/status/events/__tests__/route.test.tsの Prisma モックでTS2339: Property 'mockResolvedValue' does not existが 33 件発生します。この型エラーは既存のもの
next のアップデートで新たに壊れたわけではなく、現在の
devでもnpx tsc --noEmitは同じ 33 件のエラーで落ちます。next 16.2 系のビルドがテストファイルを型チェックしていなかったため表面化していなかっただけです。vi.mockのファクトリ戻り値は import 側の型に反映されないため、prisma.serviceDefinition.findUnique.mockResolvedValue(...)は実際の Prisma のメソッド型に対して解決されて型エラーになります。変更内容
apps/status/tsconfig.jsonのexcludeに**/__tests__/**を追加し、next 16.2 系までと同じ状態に揃えます。vitest は
app/**/__tests__/**を自身のvitest.config.tsで解決して実行するため、テスト実行には影響しません。検証
npx tsc --noEmitnpm test(vitest)npm run build -w status(next 16.2.11)npm run build -w status(next 16.3.1 + postcss 8.5.26)残課題
テスト内の Prisma モックに型が付いていない状態自体は解消していません。テストの型安全性を取り戻す場合は
vi.mocked()を使った書き換えが別途必要です。🤖 Generated with Claude Code
https://claude.ai/code/session_017fQPt7HiEU36J6ontEjw9h
Summary by CodeRabbit