next.js
f7d48705 - test(typed-routes): fix flaky tests by increasing retry timeout (#91923)

Commit
18 days ago
test(typed-routes): fix flaky tests by increasing retry timeout (#91923) ## Fixing a bug ### What? Three tests in `test/e2e/app-dir/typed-routes/typed-routes.test.ts` were intermittently failing with `Failed to retry within 3000ms`: - `typed-routes › should generate route types correctly` - `typed-routes › should have passing tsc after start` - `typed-routes › should correctly convert custom route patterns from path-to-regexp to bracket syntax` ### Why? The test harness marks the dev server as "ready" when it sees `✓ Ready in X` in stdout. However, the server logs this message _before_ completing the full initialization sequence in `start-server.ts` — specifically before `getRequestHandlers()` resolves, which chains into `setupDevBundler()`. Route type generation (`routes.d.ts`) only completes inside `setupDevBundler`'s Watchpack `aggregated` event handler. The gap between the "Ready" log and actual `routes.d.ts` completion can exceed 3000ms on loaded CI runners, causing the tests' `retry()` calls to time out before the file exists. A secondary issue in `should have passing tsc after start`: the test called `next.stop()` immediately after the server was considered ready, before `routes.d.ts` was written. This meant `tsc` ran against a project missing the generated types, causing type errors even though the server had been healthy. ### How? - Increased the `retry()` timeout from the default 3000ms to 30000ms for the three affected tests. - Added a `retry()` guard in `should have passing tsc after start` to wait for `routes.d.ts` to be present and correct _before_ stopping the server. This ensures `tsc` sees complete generated types. Verified by running the full test file 3 consecutive times locally with `NEXT_SKIP_ISOLATE=1 NEXT_TEST_MODE=dev pnpm testheadless` — all passes, all 5 tests green each run. Co-authored-by: Tobias Koppers <sokra@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
Author
Parents
Loading