ac46ffe08f
This disables tests that should not be run in a deployed environment, because they use incompatible APIs or there's no reason to test them outside of `next start`. Specifically disables for things like: - Using `next.patchFile`, `next.renameFile`, etc. - Attempting to use `next.cliOutput` to query runtime logs. When deployed, these are only build-time logs. [Latest Run](https://github.com/vercel/next.js/actions/runs/9483807368)
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('next-phase', () => {
|
|
const { next, isNextDev, skipped } = nextTestSetup({
|
|
// This test is skipped when deployed because it asserts against runtime
|
|
// logs that cannot be queried in a deployed environment.
|
|
skipDeployment: true,
|
|
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
|
|
}
|
|
`,
|
|
},
|
|
})
|
|
|
|
if (skipped) return
|
|
|
|
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)
|
|
}
|
|
})
|
|
})
|