Unverified Commit c62c51e3 authored by Josh Story's avatar Josh Story Committed by GitHub

test: migrate runtime deploy exclusions to force gates (#98159)

## Summary

Migrate the remaining runtime, middleware, instrumentation, telemetry,
logging, and local-process deployment exclusions to `@force-gate` and
remove their `skipDeployment`/`skipped` control flow. This stack is
rooted at canary and independent of #98430; it preserves deployment
coverage already enabled on canary.

The sub-shell-generation-middleware migration is deferred to #98155
while its adapter deployment cache-upgrade failure is investigated. Its
test file stays byte-for-byte identical to this PR's base, preserving
the existing adapter exception and assertions.

Adds the static nodeMiddleware condition and its unit coverage. The
custom-server and OpenTelemetry files covered by #98994 are omitted.

## Verification

- Compared test registration against canary in development, production,
and deploy modes with test bodies and hooks disabled (Webpack). Existing
active deployment assertions are preserved; development/production test
selection is unchanged apart from replacing empty skip placeholders with
skipped real tests.
- Gate unit tests: 79 passed.
- TypeScript, Prettier, and ESLint checks passed. Registration probes
use a default config for lazy predicates and do not exercise fixture
setup or test bodies.
- Verified the deferred suite is absent from this PR diff and the
upper-layer patches are unchanged. Full bootstrap passed on the combined
canary-based stack after the final restack; deployment execution remains
for CI.

<!-- NEXT_JS_LLM -->

---------
Co-authored-by: 's avatarJamiboy Mohammad <jamiboym@gmail.com>
parent 8af1fab7
......@@ -93,8 +93,9 @@ Every name in a pragma must be declared in `test/lib/gate/conditions.ts`
- **static** — the run's shape: `dev`, `start`, `deploy`, `mode`, `turbopack`,
`rspack`, `webpack`, `bundler`, `react18`, `wasm`, `linux`, `macos`,
`windows`, `ci`; specialized CI variants `adapter`, `standaloneOutput`,
`turbopackDev`, and `turbopackBuild`; plus the always-false `FIXME`/`TODO`.
`windows`, `ci`; specialized CI variants `adapter`, `nodeMiddleware`,
`standaloneOutput`, `turbopackDev`, and `turbopackBuild`; plus the
always-false `FIXME`/`TODO`.
`prod` and `prefetching` are semantic aliases for `!dev` — prefer the name
that states _why_ the suite cannot run.
- **lazy** — a predicate over the fixture's _resolved_ `next.config`
......
import { nextTestSetup } from 'e2e-utils'
import { check } from 'next-test-utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely mutates files in the isolated local fixture after setup.
// @force-gate !deploy
describe('app-dir edge SSR', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
it('should handle edge only routes', async () => {
const appHtml = await next.render('/edge/basic')
expect(appHtml).toContain('<p>Edge!</p>')
......
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('instrumentation-order', () => {
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
it('should work', async () => {
......
......@@ -3,16 +3,14 @@ import path from 'path'
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely reads files from the isolated local fixture.
// @force-gate !deploy
describe('log-file', () => {
const { next, isNextDev, skipped } = nextTestSetup({
const { next, isNextDev } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
function getLogFilePath(): string {
const logFilePath = path.join(
next.testDir,
......
......@@ -43,9 +43,11 @@ function parseLogsFromCli(cliOutput: string) {
}, [])
}
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('app-dir - fetch logging', () => {
const { next, isNextDev } = nextTestSetup({
skipDeployment: true,
files: __dirname,
})
......@@ -79,12 +81,13 @@ describe('app-dir - fetch logging', () => {
})
})
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('app-dir - logging', () => {
const { next, isNextDev, skipped } = nextTestSetup({
skipDeployment: true,
const { next, isNextDev } = nextTestSetup({
files: __dirname,
})
if (skipped) return
function runTests({
withFetchesLogging,
withFullUrlFetches = false,
......
import { retry } from 'next-test-utils'
import { nextTestSetup } from 'e2e-utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('app-dir - fetch warnings', () => {
const { next, skipped, isNextDev } = nextTestSetup({
skipDeployment: true,
const { next, isNextDev } = nextTestSetup({
files: __dirname,
})
if (skipped) {
return
}
beforeAll(async () => {
// we don't need verbose logging (enabled by default in this Next app) for these tests to work
// we avoid enabling it since it's not currently compatible with Turbopack.
......
import { findPort } from 'next-test-utils'
import { isNextDeploy, isNextDev, nextTestSetup } from 'e2e-utils'
import { nextTestSetup } from 'e2e-utils'
import { startExternalServer } from './external-server.mjs'
// This suite starts an external test server on a local port, which a deployed
// application could not reach, and owns its production build/start lifecycle.
// @force-gate start
describe('middleware RSC external rewrite', () => {
if (isNextDev || isNextDeploy) {
test('should not run during dev or deploy test runs', () => {})
return
}
const { next } = nextTestSetup({
files: __dirname,
skipStart: true,
......
......@@ -3,15 +3,15 @@ import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
import { REQUEST_API_NAMES } from './app/request-apis-in-promise/common'
// Deploy mode exclusion: This suite asserts local CLI or runtime logs that deployments do not expose.
// reading runtime logs is not supported in deploy tests
// @force-gate !deploy
describe('nextjs APIs in after()', () => {
const { next, skipped, isNextDev } = nextTestSetup({
const { next, isNextDev } = nextTestSetup({
files: __dirname,
skipStart: true,
skipDeployment: true, // reading runtime logs is not supported in deploy tests
})
if (skipped) return
let currentCliOutputIndex = 0
const ignorePreviousLogs = () => {
......
......@@ -21,12 +21,10 @@ const REVALIDATION_RETRY_DURATION =
const _describe = isNextDev ? describe.skip : describe
_describe.each(runtimes)('after() in %s runtime', (runtimeValue) => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
env: { WAIT_BEFORE_REVALIDATING: WAIT_BEFORE_REVALIDATING + '' },
})
if (skipped) return
const pathPrefix = '/' + runtimeValue
type PageInfo = {
......
/* eslint-env jest */
import { isNextDev, nextTestSetup } from 'e2e-utils'
import { nextTestSetup } from 'e2e-utils'
import * as Log from './utils/log'
import { setTimeout } from 'timers/promises'
// This test relies on next.build() so it can't work in dev mode.
const _describe = isNextDev ? describe.skip : describe
_describe('after() in static pages', () => {
const { next, skipped } = nextTestSetup({
// This suite relies on next.build() and local CLI logs.
// @force-gate !dev
// @force-gate !deploy
describe('after() in static pages', () => {
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true, // reading CLI logs to observe after
skipStart: true,
})
if (skipped) return
let currentCliOutputIndex = 0
beforeEach(() => {
currentCliOutputIndex = next.cliOutput.length
......
......@@ -7,14 +7,13 @@ import * as Log from './utils/log'
const runtimes = ['nodejs', 'edge']
// This suite patches fixture files and reads process-local runtime logs, which
// are unavailable after deployment.
// @force-gate !deploy
describe.each(runtimes)('after() in %s runtime', (runtimeValue) => {
const { next, isNextDeploy, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
// `patchFile` and reading runtime logs are not supported in a deployed environment
skipDeployment: true,
})
if (skipped) return
const pathPrefix = '/' + runtimeValue
let currentCliOutputIndex = 0
......@@ -218,91 +217,89 @@ describe.each(runtimes)('after() in %s runtime', (runtimeValue) => {
})
})
if (!isNextDeploy) {
it('only runs callbacks after the response is fully sent', async () => {
const pageStartedFetching = promiseWithResolvers<void>()
pageStartedFetching.promise.catch(() => {})
const shouldSendResponse = promiseWithResolvers<void>()
shouldSendResponse.promise.catch(() => {})
it('only runs callbacks after the response is fully sent', async () => {
const pageStartedFetching = promiseWithResolvers<void>()
pageStartedFetching.promise.catch(() => {})
const shouldSendResponse = promiseWithResolvers<void>()
shouldSendResponse.promise.catch(() => {})
const abort = (error: Error) => {
pageStartedFetching.reject(
new Error('pageStartedFetching was aborted', { cause: error })
)
shouldSendResponse.reject(
new Error('shouldSendResponse was aborted', {
cause: error,
})
)
}
const abort = (error: Error) => {
pageStartedFetching.reject(
new Error('pageStartedFetching was aborted', { cause: error })
)
shouldSendResponse.reject(
new Error('shouldSendResponse was aborted', {
cause: error,
})
)
}
const proxyServer = await createProxyServer({
async onFetch(_, request) {
if (request.url === 'https://example.test/delayed-request') {
pageStartedFetching.resolve()
await shouldSendResponse.promise
return new Response('')
}
},
})
const proxyServer = await createProxyServer({
async onFetch(_, request) {
if (request.url === 'https://example.test/delayed-request') {
pageStartedFetching.resolve()
await shouldSendResponse.promise
return new Response('')
}
},
})
try {
const pendingReq = next
.fetch(pathPrefix + '/delay', {
headers: { 'Next-Test-Proxy-Port': String(proxyServer.port) },
})
.then(
async (res) => {
if (res.status !== 200) {
const err = new Error(
`Got non-200 response (${res.status}) for ${res.url}, aborting`
)
abort(err)
throw err
}
return res
},
(err) => {
try {
const pendingReq = next
.fetch(pathPrefix + '/delay', {
headers: { 'Next-Test-Proxy-Port': String(proxyServer.port) },
})
.then(
async (res) => {
if (res.status !== 200) {
const err = new Error(
`Got non-200 response (${res.status}) for ${res.url}, aborting`
)
abort(err)
throw err
}
)
await Promise.race([
pageStartedFetching.promise,
pendingReq, // if the page throws before it starts fetching, we want to catch that
timeoutPromise(
10_000,
'Timeout while waiting for the page to call fetch'
),
])
return res
},
(err) => {
abort(err)
throw err
}
)
await Promise.race([
pageStartedFetching.promise,
pendingReq, // if the page throws before it starts fetching, we want to catch that
timeoutPromise(
10_000,
'Timeout while waiting for the page to call fetch'
),
])
// we blocked the request from completing, so there should be no logs yet,
// because after() shouldn't run callbacks until the request is finished.
expect(getLogs()).not.toContainEqual({
source: '[page] /delay (Page)',
})
expect(getLogs()).not.toContainEqual({
source: '[page] /delay (Inner)',
})
// we blocked the request from completing, so there should be no logs yet,
// because after() shouldn't run callbacks until the request is finished.
expect(getLogs()).not.toContainEqual({
shouldSendResponse.resolve()
await pendingReq.then((res) => res.text())
// the request is finished, so after() should run, and the logs should appear now.
await retry(() => {
expect(getLogs()).toContainEqual({
source: '[page] /delay (Page)',
})
expect(getLogs()).not.toContainEqual({
expect(getLogs()).toContainEqual({
source: '[page] /delay (Inner)',
})
shouldSendResponse.resolve()
await pendingReq.then((res) => res.text())
// the request is finished, so after() should run, and the logs should appear now.
await retry(() => {
expect(getLogs()).toContainEqual({
source: '[page] /delay (Page)',
})
expect(getLogs()).toContainEqual({
source: '[page] /delay (Inner)',
})
})
} finally {
proxyServer.close()
}
})
}
})
} finally {
proxyServer.close()
}
})
it('runs in generateMetadata()', async () => {
await next.browser(pathPrefix + '/123/with-metadata')
......
import { isNextDev, nextTestSetup } from 'e2e-utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// No deploy-specific incompatibility is documented.
// @force-gate !deploy
describe('node-worker-threads', () => {
const { next, skipped, isTurbopack } = nextTestSetup({
const { next, isTurbopack } = nextTestSetup({
files: __dirname,
skipDeployment: true,
dependencies: {
pino: '9.6.0',
jspdf: '4.2.1',
},
})
if (skipped) {
return
}
// These tests are Turbopack-specific since they rely on Turbopack's worker bundling
if (!isTurbopack) {
it.skip('webpack doesnt support bundling worker-threads', () => {})
......
......@@ -4,10 +4,12 @@ import { type Collector, connectCollector } from './collector'
const COLLECTOR_PORT = 9876
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// No deploy-specific incompatibility is documented.
// @force-gate !deploy
describe('otel-parent-span-propagation', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
dependencies: require('./package.json').dependencies,
env: {
TEST_OTEL_COLLECTOR_PORT: String(COLLECTOR_PORT),
......@@ -15,10 +17,6 @@ describe('otel-parent-span-propagation', () => {
},
})
if (skipped) {
return
}
let collector: Collector
beforeEach(async () => {
......
......@@ -3,12 +3,10 @@ import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
describe('setting cookies', () => {
const { next, isNextDeploy, skipped } = nextTestSetup({
const { next, isNextDeploy } = nextTestSetup({
files: __dirname,
})
if (skipped) return
let currentCliOutputIndex = 0
beforeEach(() => {
resetCliOutput()
......@@ -71,53 +69,54 @@ describe('setting cookies', () => {
// these tests inspect CLI logs to see what happened in after,
// so they won't work in deploy mode
if (!isNextDeploy) {
it('from an action to after via closure', async () => {
const path = '/cookies/action-to-after/via-closure'
const session = await next.browser(path)
// trigger an action
await session.elementByCss('[type="submit"]').click()
await retry(async () => {
// the .set() in after should error
expect(getCliOutput()).toMatch(EXPECTED_ERROR_IN_AFTER)
})
// no cookie should be set
expect(await session.eval('document.cookie')).not.toInclude(
'illegalCookie'
)
// @force-gate !deploy
it('from an action to after via closure', async () => {
const path = '/cookies/action-to-after/via-closure'
const session = await next.browser(path)
// trigger an action
await session.elementByCss('[type="submit"]').click()
await retry(async () => {
// the .set() in after should error
expect(getCliOutput()).toMatch(EXPECTED_ERROR_IN_AFTER)
})
it('from a route handler to after via closure', async () => {
const path = '/cookies/route-handler-to-after/via-closure'
const response = await next.fetch(path, { method: 'POST' })
await response.text()
expect(response.status).toBe(200)
// no cookie should be set
expect(await session.eval('document.cookie')).not.toInclude(
'illegalCookie'
)
})
// @force-gate !deploy
it('from a route handler to after via closure', async () => {
const path = '/cookies/route-handler-to-after/via-closure'
const response = await next.fetch(path, { method: 'POST' })
await response.text()
expect(response.status).toBe(200)
// no cookie should be set
expect(response.headers.get('set-cookie')).toBe(null)
// no cookie should be set
expect(response.headers.get('set-cookie')).toBe(null)
// the .set() in after should error
await retry(async () => {
expect(getCliOutput()).toMatch(EXPECTED_ERROR_IN_AFTER)
})
// the .set() in after should error
await retry(async () => {
expect(getCliOutput()).toMatch(EXPECTED_ERROR_IN_AFTER)
})
})
it('from middleware to after via closure', async () => {
const path = '/cookies/middleware-to-after/via-closure'
const response = await next.fetch(path)
await response.text()
expect(response.status).toBe(200)
// @force-gate !deploy
it('from middleware to after via closure', async () => {
const path = '/cookies/middleware-to-after/via-closure'
const response = await next.fetch(path)
await response.text()
expect(response.status).toBe(200)
// no cookie should be set
expect(response.headers.get('set-cookie')).toBe(null)
// no cookie should be set
expect(response.headers.get('set-cookie')).toBe(null)
// the .set() in after should error
await retry(async () => {
expect(getCliOutput()).toMatch(EXPECTED_ERROR_IN_AFTER)
})
// the .set() in after should error
await retry(async () => {
expect(getCliOutput()).toMatch(EXPECTED_ERROR_IN_AFTER)
})
}
})
})
})
......@@ -2,14 +2,14 @@ import stripAnsi from 'strip-ansi'
import { retry } from 'next-test-utils'
import { nextTestSetup } from 'e2e-utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('server-action-logging', () => {
const { next, isNextStart, skipped } = nextTestSetup({
skipDeployment: true,
const { next, isNextStart } = nextTestSetup({
files: __dirname,
})
if (skipped) return
if (isNextStart) {
it('should not log server actions in production mode', async () => {
const browser = await next.browser('/')
......@@ -188,17 +188,17 @@ describe('server-action-logging', () => {
})
})
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('server-action-logging when logging.serverFunctions is disabled', () => {
const { next, isNextDev, skipped } = nextTestSetup({
skipDeployment: true,
const { next, isNextDev } = nextTestSetup({
files: __dirname,
env: {
NEXT_TEST_SERVER_FUNCTION_LOGGING: 'false',
},
})
if (skipped) return
it('should not log server actions', async () => {
const browser = await next.browser('/')
const outputIndex = next.cliOutput.length
......
......@@ -122,25 +122,25 @@ async function resolveSourceMapLikeADebugger(
return { sourceMap: JSON.parse(data), mapURL: null }
}
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('app-dir - server source maps - fake frame source maps', () => {
const dependencies = {
// `link:` simulates a package in a monorepo
'internal-pkg': `link:./internal-pkg`,
'external-pkg': `file:./external-pkg`,
}
const { skipped, next, isNextDev, isTurbopack } = nextTestSetup({
const { next, isNextDev, isTurbopack } = nextTestSetup({
dependencies,
files: path.join(__dirname, 'fixtures/default'),
// This suite requires runtime logs and a local Node.js inspector.
skipDeployment: true,
// Use the declared pnpm version on Vercel to install link: dependencies.
env: { ENABLE_EXPERIMENTAL_COREPACK: '1' },
// Expose the inspector on a random port.
startArgs: ['--inspect=0'],
})
if (skipped) return
async function findServerInspectorTarget(): Promise<InspectorTarget> {
const ports = [
...new Set(
......
......@@ -7,16 +7,15 @@ function normalizeCliOutput(output: string) {
return stripAnsi(output)
}
// Deploy mode exclusion: This suite asserts local CLI or runtime logs that deployments do not expose.
// Deploy tests don't have access to runtime logs.
// Manually verify that the runtime logs match.
// @force-gate !deploy
describe('app-dir - server source maps edge runtime', () => {
const { skipped, next, isNextDev } = nextTestSetup({
const { next, isNextDev } = nextTestSetup({
files: path.join(__dirname, 'fixtures/edge'),
// Deploy tests don't have access to runtime logs.
// Manually verify that the runtime logs match.
skipDeployment: true,
})
if (skipped) return
it('logged errors have a sourcemapped stack with a codeframe', async () => {
const outputIndex = next.cliOutput.length
await next.render('/rsc-error-log')
......
......@@ -12,23 +12,24 @@ function normalizeCliOutput(output: string) {
)
}
// Deploy mode exclusion: This suite asserts local CLI or runtime logs that deployments do not expose.
// Deploy tests don't have access to runtime logs.
// Manually verify that the runtime logs match.
// @force-gate !deploy
describe('app-dir - server source maps', () => {
const dependencies = {
// `link:` simulates a package in a monorepo
'internal-pkg': `link:./internal-pkg`,
'external-pkg': `file:./external-pkg`,
}
const { skipped, next, isNextDev, isTurbopack, isRspack } = nextTestSetup({
const { next, isNextDev, isTurbopack, isRspack } = nextTestSetup({
dependencies,
files: path.join(__dirname, 'fixtures/default'),
// Deploy tests don't have access to runtime logs.
skipDeployment: true,
// Use the declared pnpm version on Vercel to install link: dependencies.
env: { ENABLE_EXPERIMENTAL_COREPACK: '1' },
})
if (skipped) return
it('logged errors have a sourcemapped stack with a codeframe', async () => {
if (isNextDev) {
const outputIndex = next.cliOutput.length
......
......@@ -9,17 +9,14 @@ function getSetCookieHeaders(res: Response): ReadonlyArray<string> {
)
}
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// TODO: re-enable once this behavior is corrected on deploy
// @force-gate !deploy
describe('set-cookies', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
// TODO: re-enable once this behavior is corrected on deploy
skipDeployment: true,
})
if (skipped) {
return
}
describe.each([
{ dir: 'pages', runtimes: ['edge', 'experimental-edge', 'node'] },
{ dir: 'app', runtimes: ['edge', 'node'] },
......
......@@ -2,16 +2,14 @@ import { nextTestSetup } from 'e2e-utils'
import { retry, waitFor } from 'next-test-utils'
import stripAnsi from 'strip-ansi'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('unhandled-rejection-logging', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
it('logs an unhandled rejection', async () => {
const outputIndex = next.cliOutput.length
await next.fetch('/')
......
import { nextTestSetup } from 'e2e-utils'
import { fetchViaRawHttp } from 'next-test-utils'
// Deploy mode exclusion: The assertions exercise behavior specific to the local Next.js server.
// This test is skipped because it sends requests with manipulated host headers
// which doesn't work in a deployed environment
// @force-gate !deploy
describe('x-forwarded-headers', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
// This test is skipped because it sends requests with manipulated host headers
// which doesn't work in a deployed environment
skipDeployment: true,
})
if (skipped) return
it('should include x-forwarded-* headers', async () => {
const res = await next.fetch('/')
const headers = await res.json()
......
import { nextTestSetup, isNextDeploy } from 'e2e-utils'
import { nextTestSetup } from 'e2e-utils'
import { pathExists, readdir } from 'fs-extra'
import { join } from 'path'
import { retry } from 'next-test-utils'
// This suite controls a local `next start` process and inspects generated profile files.
// @force-gate start
describe('CPU Profiling - next start', () => {
const { next, isNextDev, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
startCommand: 'pnpm next start --experimental-cpu-prof',
dependencies: {},
skipStart: true, // Skip auto-start to avoid failure in dev/deploy mode
})
// CPU profiling only works with local `next start`, not dev or deploy modes
if (isNextDev || isNextDeploy || skipped) {
it('skip for development/deploy mode', () => {})
return
}
beforeAll(async () => {
await next.start()
})
......
......@@ -2,14 +2,15 @@ import { nextTestSetup, isNextDev } from 'e2e-utils'
import { join } from 'path'
import { runTests } from '../dynamic-routing/shared'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely mutates files in the isolated local fixture after setup.
// @force-gate !deploy
describe('Dynamic Routing with Middleware', () => {
const { next, isTurbopack, skipped } = nextTestSetup({
const { next, isTurbopack } = nextTestSetup({
files: join(__dirname, '../dynamic-routing'),
skipStart: true,
disableAutoSkewProtection: true,
skipDeployment: true,
})
if (skipped) return
beforeAll(async () => {
await next.patchFile(
......
import { nextTestSetup } from 'e2e-utils'
import { fetchViaHTTP } from 'next-test-utils'
// Deploy mode exclusion: This suite manually creates a package in the local `node_modules` directory.
// @force-gate !deploy
describe('Edge compiler module exports preference', () => {
if ((global as any).isNextDeploy) {
// this test is skipped when deployed because it manually creates a package in the node_modules directory
// which is unsupported
it('should skip next deploy', () => {})
return
}
const { next } = nextTestSetup({
files: {
'pages/index.js': `
......
import { isNextDev, isNextStart, nextTestSetup } from 'e2e-utils'
import { isNextDev, nextTestSetup } from 'e2e-utils'
import { join } from 'path'
import stripAnsi from 'strip-ansi'
const pagePath = 'pages/index.jsx'
const apiPath = 'pages/api/edge.js'
;(process.env.IS_TURBOPACK_TEST ? describe.skip.each : describe.each)([
// Deploy mode exclusion: This suite mutates fixture files and asserts local build and CLI output.
// @force-gate !turbopack && !deploy
describe.each([
{ appDir: join(__dirname, './app/src'), title: 'src/pages and API routes' },
{ appDir: join(__dirname, './app'), title: 'pages and API routes' },
])('Configurable runtime for $title', ({ appDir }) => {
......@@ -88,7 +90,7 @@ const apiPath = 'pages/api/edge.js'
expect(next.cliOutput).not.toInclude('warn')
})
})
} else if (isNextStart) {
} else {
describe('In start mode', () => {
const { next } = nextTestSetup({
files: appDir,
......@@ -138,7 +140,5 @@ const apiPath = 'pages/api/edge.js'
)
})
})
} else {
it.skip('no deploy tests', () => {})
}
})
import { nextTestSetup } from 'e2e-utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// Assertions don't apply to deploy mode (output differs vs. local Next.js server).
// @force-gate !deploy
describe('Edge runtime response error', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
disableAutoSkewProtection: true,
// Assertions don't apply to deploy mode (output differs vs. local Next.js server).
skipDeployment: true,
})
if (skipped) return
describe.each([
{ title: 'Edge API', url: '/api/route' },
......
......@@ -2,14 +2,14 @@ import stripAnsi from 'next/dist/compiled/strip-ansi'
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// Assertions don't apply to deploy mode (output differs vs. local Next.js server).
// @force-gate !deploy
describe('edge-runtime-streaming-error', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
disableAutoSkewProtection: true,
// Assertions don't apply to deploy mode (output differs vs. local Next.js server).
skipDeployment: true,
})
if (skipped) return
it('logs the error correctly', async () => {
const res = await next.fetch('/api/test')
......
......@@ -2,17 +2,14 @@ import { nextTestSetup } from 'e2e-utils'
const enableCacheComponents = process.env.__NEXT_CACHE_COMPONENTS === 'true'
// Deploy mode exclusion: The assertions exercise behavior specific to the local Next.js server.
// This is testing the edge runtime sandbox, which is only used in `next start`.
// @force-gate !deploy
describe('edge-runtime-timer-this', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
// This is testing the edge runtime sandbox, which is only used in `next start`.
skipDeployment: true,
})
if (skipped) {
return
}
if (enableCacheComponents) {
it.skip('skipped because `runtime = "edge"` is not allowed in cacheComponents', () => {})
return
......
......@@ -27,18 +27,18 @@ const unsupportedClasses = [
'WritableStreamDefaultController',
]
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// Vercel deployment fails to build/deploy this fixture in CI; skip in deploy mode.
// @force-gate !deploy
describe('Edge runtime with Node.js APIs', () => {
const { next, isNextDev, skipped } = nextTestSetup({
const { next, isNextDev } = nextTestSetup({
files: __dirname,
// Turbopack builds fail (non-zero exit) when edge code uses Node.js APIs,
// but the CLI output still contains the warnings we're asserting on. Skip
// the automatic start so we can run the build manually and ignore the
// non-zero exit code.
skipStart: true,
// Vercel deployment fails to build/deploy this fixture in CI; skip in deploy mode.
skipDeployment: true,
})
if (skipped) return
beforeAll(async () => {
if (isNextDev) {
......
......@@ -2,17 +2,14 @@ import { nextTestSetup } from 'e2e-utils'
import { check } from 'next-test-utils'
import stripAnsi from 'strip-ansi'
// Deploy mode exclusion: This suite asserts local CLI or runtime logs that deployments do not expose.
// don't have access to runtime logs on deploy
// @force-gate !deploy
describe('fetch failures have good stack traces in edge runtime', () => {
const { next, isNextStart, isNextDev, skipped } = nextTestSetup({
const { next, isNextStart, isNextDev } = nextTestSetup({
files: __dirname,
// don't have access to runtime logs on deploy
skipDeployment: true,
})
if (skipped) {
return
}
// TODO: Failure is not specific to Turbopack, edge runtime errors don't have source maps applied.
;(process.env.IS_TURBOPACK_TEST && isNextStart ? it.skip : it)(
'when awaiting `fetch` using an unknown domain, stack traces are preserved',
......
......@@ -4,17 +4,17 @@ import { join } from 'path'
import { nextTestSetup } from 'e2e-utils'
import { fetchViaRawHttp } from 'next-test-utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// Vercel's edge rejects malformed URLs (mixed-encoding traversal,
// backslash, double-encoded, etc.) before they reach the runtime, and
// `safeFetch` for those paths uses `localhost:0` which doesn't apply in
// deploy mode. The traversal protection we want to test here is local to
// Next.js's server.
// @force-gate !deploy
describe('file-serving', () => {
const { next, isNextDeploy, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
// Vercel's edge rejects malformed URLs (mixed-encoding traversal,
// backslash, double-encoded, etc.) before they reach the runtime, and
// `safeFetch` for those paths uses `localhost:0` which doesn't apply in
// deploy mode. The traversal protection we want to test here is local to
// Next.js's server.
skipDeployment: true,
})
if (skipped) return
// Helper to detect malformed URLs that can't be parsed by the URL constructor
const isMalformedUrl = (path) => {
......@@ -105,16 +105,11 @@ describe('file-serving', () => {
// Vercel's deploy infrastructure only serves `public/` as static assets, not
// a top-level `static/` directory, so this case is local-only.
;(isNextDeploy ? it.skip : it)(
'should serve file with space correctly static/',
async () => {
const res = await next.fetch('/static/hello world.txt')
// eslint-disable-next-line jest/no-standalone-expect
expect(res.status).toBe(200)
// eslint-disable-next-line jest/no-standalone-expect
expect(await res.text()).toBe('hi')
}
)
it('should serve file with space correctly static/', async () => {
const res = await next.fetch('/static/hello world.txt')
expect(res.status).toBe(200)
expect(await res.text()).toBe('hi')
})
it('should serve avif image with correct content-type', async () => {
// vercel-icon-dark.avif is downloaded from https://vercel.com/design and transformed to avif on avif.io
......
import { nextTestSetup } from 'e2e-utils'
import { check } from 'next-test-utils'
describe('instrumentation-hook-rsc', () => {
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('instrumentation', () => {
const { next, isNextDev, skipped } = nextTestSetup({
const { next, isNextDev } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
it('should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook/)
......
......@@ -4,15 +4,12 @@ import path from 'path'
const describeCase = (
caseName: string,
callback: (context: ReturnType<typeof nextTestSetup>) => void,
{ skipDeployment = false }: { skipDeployment?: boolean } = {}
callback: (context: ReturnType<typeof nextTestSetup>) => void
) => {
describe(caseName, () => {
const context = nextTestSetup({
files: path.join(__dirname, caseName),
skipDeployment,
})
if (context.skipped) return
callback(context)
})
......
import { nextTestSetup } from 'e2e-utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('instrumentation-hook - register-once', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
it('should only register once', async () => {
await next.fetch('/foo')
expect(next.cliOutput).toIncludeRepeated('register-log', 1)
......
import { nextTestSetup, isNextDev, isNextStart } from 'e2e-utils'
import { retry } from 'next-test-utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('Errors on invalid custom middleware matchers', () => {
const { next, isTurbopack, skipped } = nextTestSetup({
const { next, isTurbopack } = nextTestSetup({
files: __dirname,
skipStart: true,
skipDeployment: true,
})
if (skipped) return
afterEach(async () => {
await next.deleteFile('middleware.js').catch(() => {})
......
......@@ -3,15 +3,10 @@ import { join } from 'path'
import { fetchViaHTTP, fetchViaRawHttp } from 'next-test-utils'
import { FileRef, nextTestSetup } from 'e2e-utils'
const itif = (condition: boolean) => (condition ? it : it.skip)
const isModeDeploy = process.env.NEXT_TEST_MODE === 'deploy'
// TODO(deploy-test-completion): Re-enable this suite for deployed Node.js middleware.
// No deploy-specific incompatibility is documented.
// @force-gate !deploy || !nodeMiddleware
describe('Middleware custom matchers', () => {
if ((global as any).isNextDeploy && process.env.TEST_NODE_MIDDLEWARE) {
return it('should skip deploy for now', () => {})
}
const { next } = nextTestSetup({
files: new FileRef(join(__dirname, '../app')),
overrideFiles: process.env.TEST_NODE_MIDDLEWARE
......@@ -103,8 +98,9 @@ describe('Middleware custom matchers', () => {
expect(res2.status).toBe(404)
})
// Cannot modify host when testing with real deployment
itif(!isModeDeploy)('should match has host', async () => {
// Cannot modify host when testing with a real deployment.
// @force-gate !deploy
it('should match has host', async () => {
const res1 = await fetchViaHTTP(next.url, '/has-match-4')
expect(res1.status).toBe(404)
......@@ -144,20 +140,16 @@ describe('Middleware custom matchers', () => {
// FIXME: Test fails on Vercel deployment for now.
// See https://linear.app/vercel/issue/EC-160/header-value-set-on-middleware-is-not-propagated-on-client-request-of
itif(!isModeDeploy)(
'should match has query on client routing',
async () => {
const browser = await next.browser('/routes')
await browser.eval('window.__TEST_NO_RELOAD = true')
await browser.elementById('has-match-2').click()
const fromMiddleware = await browser
.elementById('from-middleware')
.text()
expect(fromMiddleware).toBe('true')
const noReload = await browser.eval('window.__TEST_NO_RELOAD')
expect(noReload).toBe(true)
}
)
// @force-gate !deploy
it('should match has query on client routing', async () => {
const browser = await next.browser('/routes')
await browser.eval('window.__TEST_NO_RELOAD = true')
await browser.elementById('has-match-2').click()
const fromMiddleware = await browser.elementById('from-middleware').text()
expect(fromMiddleware).toBe('true')
const noReload = await browser.eval('window.__TEST_NO_RELOAD')
expect(noReload).toBe(true)
})
it('should match has cookie on client routing', async () => {
const browser = await next.browser('/routes')
......
......@@ -30,6 +30,8 @@ function normalizeMiddlewareManifest(value: unknown, key?: string): unknown {
return value
}
// TODO(deploy-test-completion): Remove this suite from the deploy manifest.
// It was excluded as a known deploy failure without a documented root cause.
describe('Middleware can set the matcher in its config', () => {
const { next } = nextTestSetup({
files: new FileRef(join(__dirname, 'app')),
......
......@@ -6,9 +6,9 @@ import { check, fetchViaHTTP, retry } from 'next-test-utils'
import { FileRef, nextTestSetup } from 'e2e-utils'
import escapeStringRegexp from 'escape-string-regexp'
const isTurbopackTest = Boolean(process.env.IS_TURBOPACK_TEST)
const isAdapterTest = process.env.NEXT_ENABLE_ADAPTER === '1'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// FIXME: Fails to deploy
// @force-gate !deploy || !adapter || !turbopack
describe('Middleware Rewrite', () => {
const { next, isNextDeploy } = nextTestSetup({
files: {
......@@ -16,8 +16,6 @@ describe('Middleware Rewrite', () => {
'next.config.js': new FileRef(join(__dirname, '../app/next.config.js')),
'middleware.js': new FileRef(join(__dirname, '../app/middleware.js')),
},
// FIXME: Fails to deploy
skipDeployment: isAdapterTest && isTurbopackTest,
})
function tests() {
......@@ -196,12 +194,9 @@ describe('Middleware Rewrite', () => {
expect(await browser.eval('next.router.asPath')).toBe('/param-1')
})
// TODO: investigate test failure during client navigation on deployment.
// @force-gate !deploy
it('should have props for afterFiles rewrite to SSG page', async () => {
// TODO: investigate test failure during client navigation
// on deployment
if ((global as any).isNextDeploy) {
return
}
let browser = await next.browser('/')
await browser.eval(`next.router.push("/afterfiles-rewrite-ssg")`)
......@@ -866,20 +861,20 @@ describe('Middleware Rewrite', () => {
}
})
if (!(global as any).isNextDeploy) {
it(`${label}should rewrite when not using localhost`, async () => {
const customUrl = new URL(next.url)
customUrl.hostname = 'localtest.me'
// This assertion uses a local hostname to reach the test server.
// @force-gate !deploy
it(`${label}should rewrite when not using localhost`, async () => {
const customUrl = new URL(next.url)
customUrl.hostname = 'localtest.me'
const res = await fetchViaHTTP(
customUrl.toString(),
`${locale}/rewrite-me-without-hard-navigation`
)
const html = await res.text()
const $ = cheerio.load(html)
expect($('.title').text()).toBe('About Page')
})
}
const res = await fetchViaHTTP(
customUrl.toString(),
`${locale}/rewrite-me-without-hard-navigation`
)
const html = await res.text()
const $ = cheerio.load(html)
expect($('.title').text()).toBe('About Page')
})
it(`${label}should rewrite to Vercel`, async () => {
const res = await fetchViaHTTP(next.url, `${locale}/rewrite-me-to-vercel`)
......
import { nextTestSetup } from 'e2e-utils'
import { createServer, Server } from 'http'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// Vercel deployment fails to build/deploy this fixture in CI; skip in deploy mode.
// @force-gate !deploy
describe('fetch-keep-alive', () => {
let mockServer: Server
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
skipStart: true,
// Vercel deployment fails to build/deploy this fixture in CI; skip in deploy mode.
skipDeployment: true,
})
if (skipped) return
beforeAll(async () => {
mockServer = createServer((req, res) => {
......
......@@ -2,16 +2,14 @@ import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
import { getOutputLogJson } from '../_testing/utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('on-request-error - basic', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
const outputLogPath = 'output-log.json'
async function validateErrorRecord({
......
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
// Deploy mode exclusion: This suite asserts local server CLI output after
// aborting a response stream.
// @force-gate !deploy
describe('on-request-error - client-abort', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
it('should not report an aborted RSC stream but still report render errors', async () => {
const controller = new AbortController()
const res = await next.fetch('/hang', {
......
......@@ -2,16 +2,14 @@ import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
import { getOutputLogJson } from '../_testing/utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('on-request-error - dynamic-routes', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
const outputLogPath = 'output-log.json'
async function getErrorRecord({ errorMessage }: { errorMessage: string }) {
......
......@@ -4,16 +4,14 @@ import { getOutputLogJson } from '../_testing/utils'
const outputLogPath = 'output-log.json'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely expects a local build failure instead of a successful deployment.
// @force-gate !deploy
describe('on-request-error - isr', () => {
const { next, skipped, isNextDev } = nextTestSetup({
const { next, isNextDev } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
if (isNextDev) {
it('should skip in development mode', () => {
// This ISR test is only applicable for production mode
......
......@@ -2,10 +2,12 @@ import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
import { getOutputLogJson } from '../_testing/utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('on-request-error - otel', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
packageJson: {
dependencies: {
'@vercel/otel': '^1.13.0',
......@@ -13,10 +15,6 @@ describe('on-request-error - otel', () => {
},
})
if (skipped) {
return
}
const outputLogPath = 'output-log.json'
async function validateErrorRecord({
......
......@@ -2,16 +2,14 @@ import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
import { getOutputLogJson } from '../_testing/utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe('on-request-error - server-action-error', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})
if (skipped) {
return
}
const outputLogPath = 'output-log.json'
async function validateErrorRecord({
......
......@@ -27,6 +27,9 @@ for (const { app, src, pathname, text } of [
text: 'Page',
},
]) {
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
describe(`instrumentation ${app ? 'app' : 'pages'}${
src ? ' src/' : ''
}`, () => {
......@@ -38,7 +41,6 @@ for (const { app, src, pathname, text } of [
env: {
NEXT_PUBLIC_SIMPLE_INSTRUMENT: '1',
},
skipDeployment: true,
packageJson: {
scripts: {
'setup-dir': `mv instrumentation-minimal.ts instrumentation.ts; rm -rf ${oppositeDir}${
......
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
// Deploy mode exclusion: This suite controls a local server or proxy process.
// the socket.io setup relies on patching next's `http.Server` instance,
// which we can't do when deployed
// @force-gate !deploy
describe('socket-io', () => {
const { next } = nextTestSetup({
files: __dirname,
......@@ -10,9 +14,6 @@ describe('socket-io', () => {
'utf-8-validate': '6.0.3',
bufferutil: '4.0.8',
},
// the socket.io setup relies on patching next's `http.Server` instance,
// which we can't do when deployed
skipDeployment: true,
})
it('should support socket.io without falling back to polling', async () => {
......
......@@ -4,14 +4,14 @@ import fs from 'fs-extra'
import { nextTestSetup } from 'e2e-utils'
import { findPort, killApp, renderViaHTTP, retry } from 'next-test-utils'
// Deploy mode exclusion: The assertions exercise behavior specific to the local Next.js server.
// Calls `next.build()` directly which is not supported on `NextDeployInstance`.
// @force-gate !deploy
describe('page features telemetry', () => {
const { next, isTurbopack, isRspack, isNextStart, skipped } = nextTestSetup({
const { next, isTurbopack, isRspack, isNextStart } = nextTestSetup({
files: __dirname,
skipStart: true,
// Calls `next.build()` directly which is not supported on `NextDeployInstance`.
skipDeployment: true,
})
if (skipped) return
async function launchDevServer(
port: number,
......
import path from 'path'
import fs from 'fs-extra'
import { isReact18, nextTestSetup } from 'e2e-utils'
import { nextTestSetup } from 'e2e-utils'
import { findAllTelemetryEvents } from 'next-test-utils'
// The telemetry suite drives multiple consecutive `next build` invocations
......@@ -9,13 +9,15 @@ import { findAllTelemetryEvents } from 'next-test-utils'
// first". The telemetry feature itself is not React-version-specific, so
// skipping under React 18 is fine until the underlying build/server lifecycle
// race is fixed.
;(isReact18 ? describe.skip : describe)('Telemetry CLI', () => {
const { next, isNextStart, isTurbopack, skipped } = nextTestSetup({
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// It likely asserts local CLI or runtime output that deploy tests do not expose.
// @force-gate !deploy
// @force-gate !react18
describe('Telemetry CLI', () => {
const { next, isNextStart, isTurbopack } = nextTestSetup({
files: __dirname,
skipStart: true,
skipDeployment: true,
})
if (skipped) return
it('can print telemetry status', async () => {
const { stdout } = await next.runCommand(['telemetry'])
......
......@@ -6,17 +6,15 @@ const PNG_1X1 = Buffer.from(
'base64'
)
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// No deploy-specific incompatibility is documented.
// @force-gate !deploy
describe('testmode', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
dependencies: require('./package.json').dependencies,
})
if (skipped) {
return
}
let proxyServer: Awaited<ReturnType<typeof createProxyServer>>
beforeEach(async () => {
......
import { nextTestSetup } from 'e2e-utils'
// TODO(deploy-test-completion): Re-enable this suite in deploy mode.
// No deploy-specific incompatibility is documented.
// @force-gate !deploy
describe('worker-react-refresh', () => {
const { next, skipped } = nextTestSetup({
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
dependencies: require('./package.json').dependencies,
})
if (skipped) {
return
}
it('does not cause any runtime errors', async () => {
const pageErrors: unknown[] = []
await next.browser('/', {
......
......@@ -86,8 +86,8 @@ There are two tiers:
`turbopack`, `rspack`, `webpack`, `bundler`, `react18`, `wasm`, `linux`,
`macos`, `windows`, `ci`), semantic aliases for `!dev` that state the reason
rather than the mode (`prod`, `prefetching`), specialized CI variants
(`adapter`, `standaloneOutput`, `turbopackDev`, `turbopackBuild`), plus
`FIXME` / `TODO`, which are always false.
(`adapter`, `nodeMiddleware`, `standaloneOutput`, `turbopackDev`,
`turbopackBuild`), plus `FIXME` / `TODO`, which are always false.
- **lazy** — a predicate over the fixture's *resolved* `next.config`
(`cacheComponents`, `ppr`, `prefetchInlining`, `output`, …), read the first
time a gate asks for it.
......
......@@ -150,6 +150,10 @@ export const conditions: Record<string, Condition> = {
adapter: staticCondition('running the adapter test variant', () =>
Boolean(process.env.NEXT_ENABLE_ADAPTER === '1')
),
nodeMiddleware: staticCondition(
'running the Node.js middleware test variant (`TEST_NODE_MIDDLEWARE`)',
() => Boolean(process.env.TEST_NODE_MIDDLEWARE)
),
standaloneOutput: staticCondition(
'running the standalone-output test variant (`TEST_OUTPUT_STANDALONE`)',
() => process.env.TEST_OUTPUT_STANDALONE === 'true'
......
......@@ -275,6 +275,40 @@ describe('@gate runtime', () => {
expect(gate.needsResolvedConfig).toBe(false)
})
it('skips only the deployed Node.js middleware variant', async () => {
const original = process.env.TEST_NODE_MIDDLEWARE
const gate = parseGate('!deploy || !nodeMiddleware', true)
try {
for (const [mode, nodeMiddleware, type] of [
['deploy', true, 'force-pass'],
['start', true, 'run'],
['deploy', false, 'run'],
] as const) {
if (nodeMiddleware) {
process.env.TEST_NODE_MIDDLEWARE = '1'
} else {
delete process.env.TEST_NODE_MIDDLEWARE
}
setGateTestContext({
mode,
bundler: 'webpack',
react18: false,
wasm: false,
})
await expect(__testing.decideGates([gate])).resolves.toMatchObject({
type,
})
}
} finally {
if (original === undefined) {
delete process.env.TEST_NODE_MIDDLEWARE
} else {
process.env.TEST_NODE_MIDDLEWARE = original
}
}
})
it('skips the test for real when the condition is false', () => {
const body = () => {}
const fakes = withFakeTestGlobals(() => {
......
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