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', () => { describe('next start without next build', () => {
it('should show error when there is no production build', async () => { it('should show error when there is no production build', async () => {
const appDir = __dirname const next = await createNext({
files: __dirname,
const result = await new Promise<{ stdout: string; stderr: string }>( skipStart: true,
(resolve) => { startCommand: `pnpm next start`,
const child = spawn('pnpm', ['next', 'start'], { serverReadyPattern: /✓ Starting.../,
cwd: appDir, })
env: {
...process.env, await next.start()
NODE_ENV: 'production', await new Promise<void>((resolve, reject) => {
}, next.on('stderr', (msg) => {
}) if (msg.includes('Could not find a production build in the')) {
resolve()
let stdout = '' }
let stderr = '' })
})
child.stdout?.on('data', (data) => {
stdout += data.toString() await next.destroy()
})
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')
}) })
}) })
...@@ -11,37 +11,21 @@ describe('instrumentation-order', () => { ...@@ -11,37 +11,21 @@ describe('instrumentation-order', () => {
await next.fetch('/') await next.fetch('/')
await retry(async () => { 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 ORDERED_LOGS = [
const instrumentationSideEffect = output.indexOf( 'instrumentation:side-effect',
'instrumentation:side-effect' 'instrumentation:register:begin',
) 'instrumentation:register:timeout',
const instrumentationBegin = output.indexOf( 'instrumentation:register:end',
'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(
'global-side-effect:app-router-page', 'global-side-effect:app-router-page',
instrumentationEnd ]
const searchedLines = cliOutputLines.filter((line) =>
ORDERED_LOGS.includes(line.trim())
) )
// All logs should be present expect(searchedLines).toEqual(ORDERED_LOGS)
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)
}) })
}) })
}) })
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