rsnext/test/e2e/next-phase/index.test.ts
Jiachi Liu 92265ccbe9
Fix next phase for next build (#60969)
In both dev server and production build we both use `getStartServerInfo`
to log the basic info but for prod build we should always respect to use
"build" phase

Fixes #57927 
Closes NEXT-2179
2024-01-22 15:37:04 +01:00

43 lines
1.3 KiB
TypeScript

import { createNextDescribe } from 'e2e-utils'
createNextDescribe(
'next-phase',
{
files: {
'app/layout.js': `export default function Layout({ children }) {
return <html><body>{children}</body></html>
}`,
'app/page.js': `export default function Page() { return <p>{'app'}</p> }`,
'pages/foo.js': `export default function Page() { return <p>{'pages'}</p> }`,
'next.config.js': `
module.exports = (phase, { defaultConfig }) => {
console.log(phase)
return defaultConfig
}
`,
},
},
({ next, isNextDev }) => {
it('should render page with next phase correctly', async () => {
const phases = {
dev: 'phase-development-server',
build: 'phase-production-build',
start: 'phase-production-server',
}
const currentPhase = isNextDev ? phases.dev : phases.build
const nonExistedPhase = isNextDev ? phases.build : phases.dev
expect(next.cliOutput).toContain(currentPhase)
expect(next.cliOutput).not.toContain(nonExistedPhase)
await next.fetch('/')
await next.fetch('/foo')
if (isNextDev) {
expect(next.cliOutput).not.toContain(phases.start)
} else {
expect(next.cliOutput).toContain(phases.start)
}
})
}
)