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