Open tschaub opened 8 years ago
that would satisfy my main use case.
Is this still the direction you want to take it? Any code written yet?
This would solve my case quite nicely as well.
Seconding this! I'm having problems mixing proxyquire and mock-fs, this would solve it!
I'll need this to keep fileception working with mock-fs 4. Or I'd need the require('mock-fs').fs(...)
feature reintroduced.
Hello,
Great tool and would love to use it, but can't. Below code doesn't work if I comment out line 1. There are other examples where a library I use attempts to lazy load its dependencies after file system was mocked for my test. Would greatly appreciate a built-in ability to use mock-fs with such libraries.
var set = require ('lodash/set');
var csv = require ('csvtojson')();
var mockfs = require ('mock-fs');
let mockfileO = {};
mockfileO[`${process.cwd()}\\test.csv`] =
'header1,header2\n' +
'data1-1,data2-1\n' +
'data1-2,data2-2\n';
mockfs (mockfileO);
let stream = require ('csvtojson')().fromFile (`${process.cwd()}\\test.csv`)
.on ('error', (err)=>{ throw new Error(err); })
.on ('end', mockfs.restore );
stream.pipe (process.stdout);
Like many others, I've run into this as a show-stopper, too. Need .fs() or this issue.
Full integration tests in particular must have access to the original file system.
An
overlay
option would make it so thefs
module operates on the in-memory filesystem for all mocked paths and operates on the real file system for all other paths.For example: