Last active
May 21, 2020 19:35
-
-
Save theKashey/5938e117f07924691b23a70d7f516076 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import test from 'ava'; | |
| import sinon from 'sinon'; | |
| // ^ uses a real FS | |
| // nothing before would be mocked | |
| import rewiremock from 'rewiremock/node'; | |
| import mockfs from 'mock-fs'; | |
| import mountfs from 'mountfs'; | |
| import fs from 'fs'; | |
| rewiremock('fs').mockThrough(); | |
| mockfs.patchInPlace(); | |
| // ^ mountfs will "patch" not real FS, but a mock :P | |
| fs.mount('/some/test/directory/', mockfs.fs({ | |
| '/some/test/directory': { | |
| 'some-file.txt': 'mock contents' | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This worked for me in a nodejs module after a small few adjustments: