You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While debugging an issue in my tests I converted this unit test from spec to jest:
describe('fs.createReadStream(path, [options])', function () {
beforeEach(function () {
mock({
'dir/source': 'source content',
});
});
afterEach(mock.restore);
test('creates a readable stream', function (done) {
const stream = fs.createReadStream('dir/source');
done();
});
});
I get the following error message when running with spec:
Error: ENOENT: no such file or directory, open 'dir/source'
Emitted 'error' event on ReadStream instance at:
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: 'dir/source'
}
I am running node 18.18.2.
Does anyone understand why this works with spec but not with jest? Wrapping this in setTimeout(.., 0) works.
The text was updated successfully, but these errors were encountered:
@isocroft Thank you for answering this. Why do I need to wrap fs.createReadStream in a promise? This is very similar to wrapping this in setTimeout(.., 0). Why does this work in spec?
While debugging an issue in my tests I converted this unit test from spec to jest:
I get the following error message when running with spec:
I am running node 18.18.2.
Does anyone understand why this works with spec but not with jest? Wrapping this in
setTimeout(.., 0)
works.The text was updated successfully, but these errors were encountered: