mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
- rename `unstable_after` -> `after` - remove `experimental.after` flag (and warn if it's present) i separated the big find-and-replace into a separate commit so that it's easier to see what else changed apart from that. does not touch docs, that's in #73038
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { isNextDev, nextTestSetup } from 'e2e-utils'
|
|
import { retry } from 'next-test-utils'
|
|
|
|
describe('after during server shutdown - custom server', () => {
|
|
const { next, skipped } = nextTestSetup({
|
|
files: __dirname,
|
|
startCommand: 'node server.mjs',
|
|
serverReadyPattern: /Custom server started/,
|
|
forcedPort: 'random',
|
|
skipStart: true,
|
|
skipDeployment: true, // the tests use cli logs and a custom server
|
|
env: {
|
|
NODE_ENV: isNextDev ? 'development' : 'production',
|
|
DEBUG: '1',
|
|
},
|
|
})
|
|
if (skipped) {
|
|
return
|
|
}
|
|
|
|
beforeEach(async () => {
|
|
await next.start()
|
|
})
|
|
|
|
afterEach(async () => {
|
|
// if the test didn't manage to kill next, we should do it ourselves
|
|
await next.stop()
|
|
}, 10_000)
|
|
|
|
// unlike the above test for `next dev`, NextCustomServer has no logic that'd cause it to skip cleanups in dev mode,
|
|
// so this is the same in both modes
|
|
it.each(['SIGINT', 'SIGTERM'] as const)(
|
|
'waits for after callbacks when the server receives %s',
|
|
async (signal) => {
|
|
await next.render('/')
|
|
await retry(async () => {
|
|
expect(next.cliOutput).toInclude('[after] starting sleep')
|
|
})
|
|
await next.stop(signal)
|
|
expect(next.cliOutput).toInclude('[after] finished sleep')
|
|
}
|
|
)
|
|
})
|