Unverified Commit 9f19d267 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[test] Deflake `typed-routes-validator` using `tsc` (#90451)

Co-authored-by: 's avatarCursor Agent <cursoragent@cursor.com>
parent aaabdcd7
import execa from 'execa' import execa from 'execa'
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { getDistDir } from 'next-test-utils' import { getDistDir, retry } from 'next-test-utils'
const strictRouteTypes = const strictRouteTypes =
process.env.__NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES === 'true' process.env.__NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES === 'true'
...@@ -42,6 +42,21 @@ describe('typed-routes-validator', () => { ...@@ -42,6 +42,21 @@ describe('typed-routes-validator', () => {
await next.build() await next.build()
} }
try { try {
if (isNextDev) {
// In dev mode, next-env.d.ts and the route type definitions it
// references (.next/types/routes.d.ts) are generated asynchronously
// after the server starts. Wait for both files to be ready with
// actual route data before running tsc.
await retry(async () => {
const envDts = await next.readFile('next-env.d.ts')
expect(envDts).toContain('reference types="next"')
const routesDts = await next.readFile(
`${getDistDir()}/types/routes.d.ts`
)
expect(routesDts).toContain('AppRoutes = "/"')
})
}
const { stdout, stderr } = await execa('pnpm', ['tsc', '--noEmit'], { const { stdout, stderr } = await execa('pnpm', ['tsc', '--noEmit'], {
cwd: next.testDir, cwd: next.testDir,
reject: false, reject: false,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment