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
In my tests I've just required mock-fs and then used:
mock({
'file.ts': fileContents,
});
I get an error:
node:fs:2486
handleErrorFromBinding(ctx);
^
Error: ENOENT: no such file or directory, lstat '/Users/ykra/projects/open-source/playwright-watch/node_modules/exit'
at Object.realpathSync (node:fs:2486:7)
at toRealPath (node:internal/modules/cjs/loader:394:13)
at tryFile (node:internal/modules/cjs/loader:390:10)
at tryExtensions (node:internal/modules/cjs/loader:402:22)
at tryPackage (node:internal/modules/cjs/loader:347:5)
at Function.Module._findPath (node:internal/modules/cjs/loader:566:18)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18) {
syscall: 'lstat',
code: 'ENOENT',
errno: -2,
path: '/Users/ykra/projects/open-source/playwright-watch/node_modules/exit'
}
If I remove the mock function call, the tests run (without the mock of course).
Any idea why this might happen?
The text was updated successfully, but these errors were encountered:
mock-fs replaces the entire file system, so there is virtually only one file on your computer: file.ts. Your program (or one of its dependencies) is trying to open the exit file which doesn't exist. You have to add the exit file in the mock:
Because mockfs is designed to monkey patch fs subsystem, normally it can only survive small scale unit test. Mock fs, test something, then restore fs.
It doesn't play well with other bigger tools which deals with file system constantly. For example jest. It will be very surprising if mockfs can work with playwright nicely.
In my tests I've just required
mock-fs
and then used:I get an error:
If I remove the
mock
function call, the tests run (without the mock of course).Any idea why this might happen?
The text was updated successfully, but these errors were encountered: