We were running scripts as they were without encompassing our logic in a function for jest's teardown and we were subsequently running `process.exit(0)` which meant that tests didn't correctly return an error status code when they failed in CI. The following tests have been skipped as well: ``` ● postgres vector custom column › should add a vector column and query it ● Sort › Local API › Orderable › should not break with existing base 62 digits ● Sort › Local API › Orderable join › should set order by default ● Sort › Local API › Orderable join › should allow setting the order with the local API ● Sort › Local API › Orderable join › should sort join docs in the correct ``` --------- Co-authored-by: Elliot DeNolf <denolfe@gmail.com> Co-authored-by: Alessio Gravili <alessio@gravili.de>
37 lines
1010 B
TypeScript
37 lines
1010 B
TypeScript
/* eslint-disable no-restricted-exports */
|
|
import { spawn } from 'child_process'
|
|
|
|
/**
|
|
* WARNING: This file MUST export a default function.
|
|
* @link https://jestjs.io/docs/configuration#globalteardown-string
|
|
*/
|
|
export default function globalTeardown() {
|
|
try {
|
|
if (global._mongoMemoryServer) {
|
|
const stopScript = `
|
|
(async () => {
|
|
await new Promise(resolve => setTimeout(resolve, 300));
|
|
try {
|
|
if (global._mongoMemoryServer) {
|
|
await global._mongoMemoryServer.stop();
|
|
console.log('Stopped memorydb');
|
|
}
|
|
} catch (error) {
|
|
console.error('Error stopping memorydb:', error);
|
|
}
|
|
})();
|
|
`
|
|
|
|
const child = spawn(process.execPath, ['-e', stopScript], {
|
|
detached: true,
|
|
stdio: 'ignore',
|
|
})
|
|
|
|
child.unref()
|
|
console.log('Spawned detached process to stop memorydb')
|
|
}
|
|
} catch (error) {
|
|
console.error('Error in globalTeardown:', error)
|
|
}
|
|
}
|