chore: fix lingering jest and next-server processes in monorepo (#8320)
This commit is contained in:
12
test/dev.ts
12
test/dev.ts
@@ -50,8 +50,14 @@ if (args.o) {
|
||||
await open(`http://localhost:3000${adminRoute}`)
|
||||
}
|
||||
|
||||
// @ts-expect-error
|
||||
await nextDev({ port: process.env.PORT || 3000, dirname: rootDir }, 'default', rootDir)
|
||||
const port = process.env.PORT ? Number(process.env.PORT) : 3000
|
||||
|
||||
await nextDev({ port }, 'default', rootDir)
|
||||
|
||||
// fetch the admin url to force a render
|
||||
void fetch(`http://localhost:${process.env.PORT || 3000}${adminRoute}`)
|
||||
void fetch(`http://localhost:${port}${adminRoute}`)
|
||||
|
||||
// This ensures that the next-server process is killed when this process is killed and doesn't linger around.
|
||||
process.on('SIGINT', function () {
|
||||
process.exit(0)
|
||||
})
|
||||
|
||||
8
test/helpers/stopMemoryDB.ts
Normal file
8
test/helpers/stopMemoryDB.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
// eslint-disable-next-line no-restricted-exports
|
||||
export default async () => {
|
||||
if (global._mongoMemoryServer) {
|
||||
console.log('Stopping memorydb...')
|
||||
await global._mongoMemoryServer.stop()
|
||||
console.log('Stopped memorydb')
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ const customJestConfig = {
|
||||
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
|
||||
|
||||
globalSetup: path.resolve(dirname, './helpers/startMemoryDB.ts'),
|
||||
globalTeardown: path.resolve(dirname, './helpers/stopMemoryDB.ts'),
|
||||
|
||||
moduleNameMapper: {
|
||||
'\\.(css|scss)$': '<rootDir>/helpers/mocks/emptyModule.js',
|
||||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
|
||||
|
||||
Reference in New Issue
Block a user