Open imcuttle opened 4 years ago
mock.load with lazy option. https://github.com/tschaub/mock-fs#loading-real-files--directories
@3cp Is it could be more functional? like below
mockFs({
'/path/filename': (options) => {
return `import foo from 'foo';\n${fs.readFileSync('/a/b/c', options)}`
}
})
No api for that now. What's that "options"?
I mean who will pass options to that func?
If no need options, you can use standard getter (not mockfs feature of-course) to delay the evaluation of file content;
const mockfs = require('mock-fs');
const fs = require('fs');
mockfs({
get ['file/name']() {
return 'hello';
}
});
const content = fs.readFileSync('file/name', 'utf8');
console.log(content);
Update: get 'file/name'() {
works too.
like