Unverified Commit e7184817 authored by Jamiboy Mohammad's avatar Jamiboy Mohammad Committed by GitHub

test: enable deploy coverage for TypeScript config errors (#98849)

## Summary
Enable deployment coverage for six TypeScript configuration-error tests
using the deferred deployment lifecycle from #98776. Assert a failed
build/deployment and the specific type error instead of using local-only
build APIs. Explicitly enable the native TypeScript loader in the two
next.config.ts fixtures that rely on top-level await, so they reach
their intended type-checking error.

## Verification
- All six fixtures passed Turbopack production/development and Webpack
production checks after the native-loader fixture correction.
- Local checks used the published native binding. Exact native and
deploy validation are pending repository CI.

<!-- NEXT_JS_LLM -->
parent 6c2e502a
import { nextTestSetup } from 'e2e-utils' import { isNextDeploy, nextTestSetup } from 'e2e-utils'
describe('next-config-ts-type-error-cjs', () => { describe('next-config-ts-type-error-cjs', () => {
// TODO: Remove this once we bump minimum Node.js version to v22 // Deploy builds use the fixture's Node version, not the test runner's.
if (!(process.features as any).typescript) { // TODO: Remove this local check once we bump minimum Node.js version to v22
if (!isNextDeploy && !(process.features as any).typescript) {
it.skip('requires `process.features.typescript` to feature detect Node.js native TS', () => {}) it.skip('requires `process.features.typescript` to feature detect Node.js native TS', () => {})
return return
} }
const { next, isNextDev, skipped } = nextTestSetup({ const { next, isNextDev } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: true, skipStart: true,
skipDeployment: true, packageJson: isNextDeploy ? { engines: { node: '22.x' } } : {},
}) })
if (skipped) {
return
}
it('should throw with type error on build (CJS)', async () => { it('should throw with type error on build (CJS)', async () => {
if (isNextDev) { if (isNextDev) {
await next.start() await next.start()
const $ = await next.render$('/') const $ = await next.render$('/')
expect($('p').text()).toBe('foo') expect($('p').text()).toBe('foo')
} else { } else {
const { cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
await expect(cliOutput).toContain( const cliOutput = next.cliOutput
expect(cliOutput).toContain(
`Type 'string' is not assignable to type 'number'.` `Type 'string' is not assignable to type 'number'.`
) )
} }
}) }, 240_000)
}) })
import { nextTestSetup } from 'e2e-utils' import { isNextDeploy, nextTestSetup } from 'e2e-utils'
describe('next-config-ts-type-error-esm', () => { describe('next-config-ts-type-error-esm', () => {
// TODO: Remove this once we bump minimum Node.js version to v22 // Deploy builds use the fixture's Node version, not the test runner's.
if (!(process.features as any).typescript) { // TODO: Remove this local check once we bump minimum Node.js version to v22
if (!isNextDeploy && !(process.features as any).typescript) {
it.skip('requires `process.features.typescript` to feature detect Node.js native TS', () => {}) it.skip('requires `process.features.typescript` to feature detect Node.js native TS', () => {})
return return
} }
const { next, isNextDev, skipped } = nextTestSetup({ const { next, isNextDev } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: true, skipStart: true,
skipDeployment: true,
packageJson: { packageJson: {
...(isNextDeploy ? { engines: { node: '22.x' } } : {}),
type: 'module', type: 'module',
}, },
}) })
if (skipped) {
return
}
it('should throw with type error on build (ESM)', async () => { it('should throw with type error on build (ESM)', async () => {
if (isNextDev) { if (isNextDev) {
await next.start() await next.start()
const $ = await next.render$('/') const $ = await next.render$('/')
expect($('p').text()).toBe('foo') expect($('p').text()).toBe('foo')
} else { } else {
const { cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
await expect(cliOutput).toContain( const cliOutput = next.cliOutput
expect(cliOutput).toContain(
`Type 'string' is not assignable to type 'number'.` `Type 'string' is not assignable to type 'number'.`
) )
} }
}) }, 240_000)
}) })
import { nextTestSetup } from 'e2e-utils' import { isNextDeploy, nextTestSetup } from 'e2e-utils'
describe('next-config-ts-type-error-cjs', () => { describe('next-config-ts-type-error-cjs', () => {
// TODO: Remove this once we bump minimum Node.js version to v22 // Deploy builds use the fixture's Node version, not the test runner's.
if (!(process.features as any).typescript) { // TODO: Remove this local check once we bump minimum Node.js version to v22
if (!isNextDeploy && !(process.features as any).typescript) {
it.skip('requires `process.features.typescript` to feature detect Node.js native TS', () => {}) it.skip('requires `process.features.typescript` to feature detect Node.js native TS', () => {})
return return
} }
const { next, isNextDev, skipped } = nextTestSetup({ const { next, isNextDev } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: true, skipStart: true,
skipDeployment: true, packageJson: isNextDeploy ? { engines: { node: '22.x' } } : {},
// Vercel environment keys cannot start with an underscore.
buildCommand: isNextDeploy
? '__NEXT_NODE_NATIVE_TS_LOADER_ENABLED=true next build'
: undefined,
}) })
if (skipped) {
return
}
it('should throw with type error on build (CJS)', async () => { it('should throw with type error on build (CJS)', async () => {
if (isNextDev) { if (isNextDev) {
await next.start() await next.start()
const $ = await next.render$('/') const $ = await next.render$('/')
expect($('p').text()).toBe('foo') expect($('p').text()).toBe('foo')
} else { } else {
const { cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
await expect(cliOutput).toContain( const cliOutput = next.cliOutput
expect(cliOutput).toContain(
`Type 'string' is not assignable to type 'number'.` `Type 'string' is not assignable to type 'number'.`
) )
} }
}) }, 240_000)
}) })
import { nextTestSetup } from 'e2e-utils' import { isNextDeploy, nextTestSetup } from 'e2e-utils'
describe('next-config-ts-type-error-esm', () => { describe('next-config-ts-type-error-esm', () => {
// TODO: Remove this once we bump minimum Node.js version to v22 // Deploy builds use the fixture's Node version, not the test runner's.
if (!(process.features as any).typescript) { // TODO: Remove this local check once we bump minimum Node.js version to v22
if (!isNextDeploy && !(process.features as any).typescript) {
it.skip('requires `process.features.typescript` to feature detect Node.js native TS', () => {}) it.skip('requires `process.features.typescript` to feature detect Node.js native TS', () => {})
return return
} }
const { next, isNextDev, skipped } = nextTestSetup({ const { next, isNextDev } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: true, skipStart: true,
skipDeployment: true, // Vercel environment keys cannot start with an underscore.
buildCommand: isNextDeploy
? '__NEXT_NODE_NATIVE_TS_LOADER_ENABLED=true next build'
: undefined,
packageJson: { packageJson: {
...(isNextDeploy ? { engines: { node: '22.x' } } : {}),
type: 'module', type: 'module',
}, },
}) })
if (skipped) {
return
}
it('should throw with type error on build (ESM)', async () => { it('should throw with type error on build (ESM)', async () => {
if (isNextDev) { if (isNextDev) {
await next.start() await next.start()
const $ = await next.render$('/') const $ = await next.render$('/')
expect($('p').text()).toBe('foo') expect($('p').text()).toBe('foo')
} else { } else {
const { cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
await expect(cliOutput).toContain( const cliOutput = next.cliOutput
expect(cliOutput).toContain(
`Type 'string' is not assignable to type 'number'.` `Type 'string' is not assignable to type 'number'.`
) )
} }
}) }, 240_000)
}) })
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
describe('next-config-ts-type-error-cjs', () => { describe('next-config-ts-type-error-cjs', () => {
const { next, isNextDev, skipped } = nextTestSetup({ const { next, isNextDev } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: true, skipStart: true,
skipDeployment: true,
}) })
if (skipped) {
return
}
it('should throw with type error on build (CJS)', async () => { it('should throw with type error on build (CJS)', async () => {
if (isNextDev) { if (isNextDev) {
await next.start() await next.start()
const $ = await next.render$('/') const $ = await next.render$('/')
expect($('p').text()).toBe('foo') expect($('p').text()).toBe('foo')
} else { } else {
const { cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
await expect(cliOutput).toContain( const cliOutput = next.cliOutput
expect(cliOutput).toContain(
`Type 'string' is not assignable to type 'number'.` `Type 'string' is not assignable to type 'number'.`
) )
} }
}) }, 240_000)
}) })
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
describe('next-config-ts-type-error-esm', () => { describe('next-config-ts-type-error-esm', () => {
const { next, isNextDev, skipped } = nextTestSetup({ const { next, isNextDev } = nextTestSetup({
files: __dirname, files: __dirname,
skipStart: true, skipStart: true,
skipDeployment: true,
packageJson: { packageJson: {
type: 'module', type: 'module',
}, },
}) })
if (skipped) {
return
}
it('should throw with type error on build (ESM)', async () => { it('should throw with type error on build (ESM)', async () => {
if (isNextDev) { if (isNextDev) {
await next.start() await next.start()
const $ = await next.render$('/') const $ = await next.render$('/')
expect($('p').text()).toBe('foo') expect($('p').text()).toBe('foo')
} else { } else {
const { cliOutput } = await next.build() await expect(next.start()).rejects.toThrow()
await expect(cliOutput).toContain( const cliOutput = next.cliOutput
expect(cliOutput).toContain(
`Type 'string' is not assignable to type 'number'.` `Type 'string' is not assignable to type 'number'.`
) )
} }
}) }, 240_000)
}) })
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