Commit e55cd63d authored by Jimmy Lai's avatar Jimmy Lai

revert: restore original tests after fixing 'Starting...' log

The test changes in commit 9af16d9c were working around the
missing 'Starting...' log. Now that the log is restored,
revert the tests to their original form.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: 's avatarClaude Opus 4.5 <noreply@anthropic.com>
parent ee3e4a9c
import { spawn } from 'child_process'
import { createNext } from 'e2e-utils'
describe('next start without next build', () => {
it('should show error when there is no production build', async () => {
const appDir = __dirname
const result = await new Promise<{ stdout: string; stderr: string }>(
(resolve) => {
const child = spawn('pnpm', ['next', 'start'], {
cwd: appDir,
env: {
...process.env,
NODE_ENV: 'production',
},
})
let stdout = ''
let stderr = ''
child.stdout?.on('data', (data) => {
stdout += data.toString()
})
child.stderr?.on('data', (data) => {
stderr += data.toString()
})
child.on('close', () => {
resolve({ stdout, stderr })
})
// Timeout after 10 seconds
setTimeout(() => {
child.kill()
resolve({ stdout, stderr })
}, 10000)
}
)
// The error message should appear in stdout (where Next.js logs errors)
const combinedOutput = result.stdout + result.stderr
expect(combinedOutput).toContain('Could not find a production build')
const next = await createNext({
files: __dirname,
skipStart: true,
startCommand: `pnpm next start`,
serverReadyPattern: /✓ Starting.../,
})
await next.start()
await new Promise<void>((resolve, reject) => {
next.on('stderr', (msg) => {
if (msg.includes('Could not find a production build in the')) {
resolve()
}
})
})
await next.destroy()
})
})
......@@ -11,37 +11,21 @@ describe('instrumentation-order', () => {
await next.fetch('/')
await retry(async () => {
const output = next.cliOutput
const serverLog = next.cliOutput.split('Starting...')[1]
const cliOutputLines = serverLog.split('\n')
// Verify instrumentation runs in correct order
const instrumentationSideEffect = output.indexOf(
'instrumentation:side-effect'
)
const instrumentationBegin = output.indexOf(
'instrumentation:register:begin'
)
const instrumentationTimeout = output.indexOf(
'instrumentation:register:timeout'
)
const instrumentationEnd = output.indexOf('instrumentation:register:end')
// Find the global side effect that comes AFTER instrumentation
const globalSideEffect = output.indexOf(
const ORDERED_LOGS = [
'instrumentation:side-effect',
'instrumentation:register:begin',
'instrumentation:register:timeout',
'instrumentation:register:end',
'global-side-effect:app-router-page',
instrumentationEnd
]
const searchedLines = cliOutputLines.filter((line) =>
ORDERED_LOGS.includes(line.trim())
)
// All logs should be present
expect(instrumentationSideEffect).toBeGreaterThan(-1)
expect(instrumentationBegin).toBeGreaterThan(-1)
expect(instrumentationTimeout).toBeGreaterThan(-1)
expect(instrumentationEnd).toBeGreaterThan(-1)
expect(globalSideEffect).toBeGreaterThan(-1)
// Verify correct order: side-effect < begin < timeout < end < global-side-effect
expect(instrumentationSideEffect).toBeLessThan(instrumentationBegin)
expect(instrumentationBegin).toBeLessThan(instrumentationTimeout)
expect(instrumentationTimeout).toBeLessThan(instrumentationEnd)
expect(instrumentationEnd).toBeLessThan(globalSideEffect)
expect(searchedLines).toEqual(ORDERED_LOGS)
})
})
})
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