tschaub / mock-fs

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

Only override process.binding('fs') #182

Closed tschaub closed 7 years ago

tschaub commented 8 years ago

This reworks how the fs module is mocked. Instead of overriding methods on the module itself, only the process.binding('fs') methods are replaced.

Possible breaking changes:

eugef commented 8 years ago

I am using Node 6.3 and Babel to transpile import statements. The current master doesn't work for me.

But this PR works for me, great job @tschaub !

Any plans to release it?

tschaub commented 8 years ago

@not-an-aardvark - Yeah, I'm aware that process.binding('fs') is not a stable feature. It turns out that the mock-fs binding works with Node 0.8 through 7. So although there have been Node releases with breaking fs changes, I've been able to maintain a single binding that has worked with them all.

@eugef - I haven't had time to address the breaking changes mentioned above. I'm personally most interested in fixing the require issue (making require consistently work with the real fs even when called lazily). Not sure which of these will affect the most users.

I'll release a beta and see if we can get some feedback.

eugef commented 7 years ago

When it would be released?

tschaub commented 7 years ago

You can install mock-fs@beta to try it out.