Open gsuess opened 3 years ago
After looking into the source-code, it doesn't seem to be possible currently.
With a bit of refactoring however, this feature could be integrated though, by adding a doNotPatch
option and return a mocked fs map that implements all interfaces that fs
exports.
You can use https://www.npmjs.com/package/memfs or https://www.npmjs.com/package/memory-fs for this purpose
I usually like to pass all environment bound interfaces as a parameter, including fs.
Here is a simple Example:
With this practice there is no necessity to temporarily disable an interface globally, which can cause some very unexpected issues (one of such issues is seen on the Readme with Jest Snapshots).
Is there a possibility to create a fs mock without actually messing with the origina fs?
With the example above, I would like to implement tests like this:
Without needing to call restore on anything.