Skip to content

fix(status): テストファイルをnext buildの型チェック対象から除外 - #226

Merged
TinyKitten merged 1 commit into
devfrom
fix/status-exclude-tests-from-build-typecheck
Aug 18, 2026
Merged

fix(status): テストファイルをnext buildの型チェック対象から除外#226
TinyKitten merged 1 commit into
devfrom
fix/status-exclude-tests-from-build-typecheck

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Aug 18, 2026

Copy link
Copy Markdown
Member

背景

#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.jsonexclude**/__tests__/** を追加し、next 16.2 系までと同じ状態に揃えます。

vitest は app/**/__tests__/** を自身の vitest.config.ts で解決して実行するため、テスト実行には影響しません。

検証

項目 結果
npx tsc --noEmit エラー 0 件 (修正前 33 件)
npm test (vitest) 8 ファイル / 68 テスト すべてパス
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

  • 設定
    • TypeScriptのチェック対象からテスト用ディレクトリを除外しました。

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
@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
trainlcd-lp-stg Ready Ready Preview Aug 18, 2026 11:34pm
trainlcd-status-stg Ready Ready Preview Aug 18, 2026 11:34pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 184eb6e0-53d4-413f-8425-5e04768b8133

📥 Commits

Reviewing files that changed from the base of the PR and between 1a7ad5b and 4f201a7.

📒 Files selected for processing (1)
  • apps/status/tsconfig.json

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.


📝 Walkthrough

Walkthrough

apps/status/tsconfig.jsonexclude 設定に **/__tests__/** を追加しました。これにより、テストディレクトリが TypeScript の対象外になります。

Changes

statusアプリのTypeScript設定

Layer / File(s) Summary
テストディレクトリの除外
apps/status/tsconfig.json
exclude 設定に **/__tests__/** を追加しました。

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 4f201

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

うさぎが跳ねて、設定を一行更新。
テストの道をそっと分離。
TypeScriptは対象を確認し、
静かなビルドへ進みます。
にんじんも一つ、祝います。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed タイトルは、テストファイルをNext.jsのビルド時の型チェック対象から除外する主要な変更を明確に示しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/status-exclude-tests-from-build-typecheck

Comment @coderabbitai help to get the list of available commands.

@TinyKitten
TinyKitten merged commit e011fee into dev Aug 18, 2026
4 checks passed
@TinyKitten
TinyKitten deleted the fix/status-exclude-tests-from-build-typecheck branch August 18, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant