tschaub / mock-fs

Configurable mock for the fs module
https://npmjs.org/package/mock-fs
Other
906 stars 85 forks source link

Mock Files Not Found When Importing Mock-Fs Multiple Times In Other Test Files #316

Open bushmecj opened 3 years ago

bushmecj commented 3 years ago

When testing a function whose job is to open files, the test will fail if another test file imports mock-fs.

I receive the following error: Error: UNKNOWN: unknown error, open MOCKED-FILE-PATH-HERE

This error disappears and the test passes when I comment out the mock-fs import in another file. The other file simply needs to import mock-fs. It does not need to actually use the package for the tests to fail.

3cp commented 3 years ago

It is very common to import mock-fs in multiple test files, pls share a minimal repo to reproduce the issue.