-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
Hello,
I've been running into an issue where an open handle prevented Jest to close.
The quick fix for now is to add a jest.teardown,js
file with this snippet:
afterAll(async () => {
// Close all open handles
const handles = process._getActiveHandles();
handles.forEach((handle) => {
if (handle.constructor.name === 'DirHandle') {
handle.close();
}
});
});
More details about the config:
"scripts": {
"safetest": "cross-env OPT_URL=${OPT_URL:-http://localhost:10088/src} react-scripts --inspect test --runInBand --detectOpenHandles --testMatch '**/*.safetest.{j,t}s{,x}' --setupFilesAfterEnv ./setup-safetest.tsx --testTimeout=30000",
"safetest:ci:test": "OPT_URL=http://localhost:10088/ OPT_ARTIFACTS=artifacts.json OPT_DOCKER=1 OPT_CI=1 npm run safetest -- --watchAll=false --json --outputFile=results.json --bail=5 --ci=1",
"safetest:ci": "(npm run safetest:ci:test || true)",
"safetest:regenerate-screenshots": "npm run safetest -- --watchAll=false --docker=1 --update-snapshot",
"process:ci": "npx safetest add-artifact-info artifacts.json results.json && cp results.json ../../../JAWS_Project/jaws/public/safetest/fleet.json"
},
And the message from the console:
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
● DIRHANDLE
1 | import { setup } from 'safetest/setup';
2 |
> 3 | setup({
| ^
4 | bootstrappedAt: require.resolve('./src/main.jsx'),
5 | ciOptions: {
6 | usingArtifactsDir: 'artifacts'
at setOptions (node_modules/safetest/src/set-options.ts:54:7)
at setup (node_modules/safetest/src/setup.ts:59:13)
at Object.<anonymous> (setup-safetest.tsx:3:6)
at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:333:13)
at runJest (node_modules/@jest/core/build/runJest.js:404:19)
at _run10000 (node_modules/@jest/core/build/cli/index.js:320:7)
at runCLI (node_modules/@jest/core/build/cli/index.js:173:3)
safetest-server-1.43.1-srn7a1rcjck
safetest-server-1.43.1-4xx2i5pvy6c
If need anything else, please let me know.
Thank you.
Metadata
Metadata
Assignees
Labels
No labels