Skip to content

Commit

Permalink
test: do not wait for unstable_after callbacks in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
lubieowoce committed Nov 11, 2024
1 parent 328a840 commit 585c54d
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 24 deletions.
45 changes: 45 additions & 0 deletions test/e2e/app-dir/graceful-shutdown-next-after/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'

describe('unstable_after during server shutdown', () => {
const { next, skipped, isNextDev } = nextTestSetup({
files: __dirname,
skipDeployment: true, // the tests use cli logs
skipStart: true,
})
if (skipped) {
return
}

beforeEach(async () => {
await next.start()
})

if (isNextDev) {
it.each(['SIGINT', 'SIGTERM'] as const)(
'does not wait for unstable_after callbacks when the server receives %s',
async (signal) => {
await next.browser('/')
await retry(async () => {
expect(next.cliOutput).toInclude('[after] starting sleep')
})
await next.stop(signal)
expect(next.cliOutput).not.toInclude('[after] finished sleep')
}
)
}

if (!isNextDev) {
it.each(['SIGINT', 'SIGTERM'] as const)(
'waits for unstable_after callbacks when the server receives %s',
async (signal) => {
await next.browser('/')
await retry(async () => {
expect(next.cliOutput).toInclude('[after] starting sleep')
})
await next.stop(signal)
expect(next.cliOutput).toInclude('[after] finished sleep')
}
)
}
})
24 changes: 0 additions & 24 deletions test/production/app-dir/graceful-shutdown-next-after/index.test.ts

This file was deleted.

0 comments on commit 585c54d

Please sign in to comment.