Closed gyandeeps closed 8 years ago
Why was this closed? How did you fix it? I have the exact same problem.
I was trying to convert a real folder structure into a mock-fs compatible json structure so I ended up doing it like this https://gist.github.com/gyandeeps/23a4c836b54f91d9d3cfed7ab37e7a0b
@TheHighriser can you provide an example that fails and describe what you are trying to do?
@gyandeeps : Thanks for the example!
@tschaub : Basically I have set up a test via Mocha.
I tried to initialize one file by doing so:
mock({
'C:/workspace/package.json' : 'My Content'
})
I tried to use this initialization pretty much everywhere but the error occurred anyways. (After using the module, before the test, exactly in the test, ..)
The error itself gets triggered by this function:
function checkIfFileExists(_file){
return new Promise(function(resolve, reject){
fs.stat(_file, function(err, stat) {
if(err){
reject("File not available: " + _file);
return;
}
resolve(_file);
});
});
}
In the _file I have the same path as used above. But I also get those weird characters like above in the error message from @gyandeeps
Is there any initialization I forgot? Or is mock(filesConfig) everything I need? As It didn't work I ended up using Stubs with Sinon and overriding those methods instead of faking the file itself. I have tested with several node versions but none of them worked.
If there is anything I should add, tell me.
what i did:
Error stack:
OS: Windows 7 Node: 6.0