tschaub / mock-fs

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

Bypass updates #306

Closed tschaub closed 4 years ago

tschaub commented 4 years ago

This is a follow-up to #304.

3cp commented 4 years ago

Instead of playing _mockedBinding, it's probably cheaper and less code if we use a boolean flag on realBinding to temporarily disable mocking.

tschaub commented 4 years ago

It looks like there will be more to do to get bypass fully working. fs.createWriteStream doesn't work with the current implementation, and process.cwd() and process.chdir() will produce unexpected results.

3cp commented 4 years ago

The patches for cwd/chdir/createWriteStream/binding should all check the same _mockedBinding (or a flag) on realBinding. This also means we only need to patch them once without real restore.

The restore (not just for bypass) only needs to remove _mockedBinding (and the flag).

I will create a draft.

3cp commented 4 years ago

Could you merge #303 first?