mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Typescript 7 came out, which is breaking a lot of our e2e tests.
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
import { check } from 'next-test-utils'
|
|
|
|
describe('correct tsconfig.json defaults', () => {
|
|
const { next } = nextTestSetup({
|
|
files: {
|
|
'pages/index.tsx': 'export default function Page() {}',
|
|
},
|
|
skipStart: true,
|
|
dependencies: {
|
|
'@types/react': 'latest',
|
|
},
|
|
})
|
|
|
|
it('should add `moduleResolution` when generating tsconfig.json in dev', async () => {
|
|
try {
|
|
expect(
|
|
await next.readFile('tsconfig.json').catch(() => false)
|
|
).toBeFalse()
|
|
|
|
await next.start()
|
|
|
|
let content: string
|
|
// wait for tsconfig to be written
|
|
await check(async () => {
|
|
content = await next.readFile('tsconfig.json')
|
|
return content && content !== '{}' ? 'ready' : 'retry'
|
|
}, 'ready')
|
|
|
|
const tsconfig = JSON.parse(content)
|
|
expect(next.cliOutput).not.toContain('moduleResolution')
|
|
|
|
expect(tsconfig.compilerOptions).toEqual(
|
|
expect.objectContaining({ moduleResolution: 'bundler' })
|
|
)
|
|
} finally {
|
|
await next.stop()
|
|
}
|
|
})
|
|
|
|
it('should not warn for `moduleResolution` when already present and valid', async () => {
|
|
try {
|
|
expect(
|
|
await next.readFile('tsconfig.json').catch(() => false)
|
|
).toBeTruthy()
|
|
|
|
await next.start()
|
|
|
|
const tsconfig = JSON.parse(await next.readFile('tsconfig.json'))
|
|
|
|
expect(tsconfig.compilerOptions).toEqual(
|
|
expect.objectContaining({ moduleResolution: 'bundler' })
|
|
)
|
|
expect(next.cliOutput).not.toContain('moduleResolution')
|
|
} finally {
|
|
await next.stop()
|
|
}
|
|
})
|
|
})
|