Closed tschaub closed 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.
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.
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.
Could you merge #303 first?
This is a follow-up to #304.