Closed
Description
Hello!
When using mock-fs
in combination with jest
an open handle FSREQCALLBACK
is created which (potentially) prevents Jest from exiting cleanly. This can be detected using jest --detectOpenHandles
(docs). This seems to happen at import/require of mock-fs
, not when calling mockFs()
to actually mock the fs.
The following is output from Jest:
yarn jest my.test.js --detectOpenHandles
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.328 s
Ran all test suites matching /my.test.js/i.
Jest has detected the following 1 open handle potentially keeping Jest from exiting:
● FSREQCALLBACK
> 1 | const mockFs = require('mock-fs');
| ^
2 |
3 |
4 | test('nothing', () => {});
at Object.<anonymous>.exports.getReadFileContextPrototype (node_modules/mock-fs/lib/readfilecontext.js:22:6)
at Object.<anonymous> (node_modules/mock-fs/lib/index.js:57:34)
at Object.<anonymous> (my.test.js:1:98)
at TestScheduler.scheduleTests (node_modules/@jest/core/build/TestScheduler.js:333:13)
at runJest (node_modules/@jest/core/build/runJest.js:401: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)
Minimal example to reproduce
// my.test.js
const mockFs = require('mock-fs');
test('nothing', () => {});
Any advice on how this might be avoided/worked around would be greatly appreciated! Thanks in advance!
Metadata
Metadata
Assignees
Labels
No labels