Open BadIdeaException opened 2 years ago
const mockfs = require('mock-fs');
const fs = require('fs');
mockfs({
'foo': {
'bar/baz' : 'hello'
}
});
const c = fs.readdirSync('foo');
console.log(c);
It outputs
[ 'bar/baz' ]
Not [ 'bar' ]
.
So the behaviour is same for 'foo'
and '/foo'
. You probably got the comparison wrong.
I checked our code, currently we only support first level deep dir name like mockfs({ 'a/b/c' : {...}})
, but not on any nested levels.
But I agree it's a good idea to do the same thing on all levels.
The following:
correctly produces a folder called
foo
containing folder calledbar
containing a file calledbaz
in the mocked file system. However, when using an absolute path as the parentI get a (top-level) folder
/foo
, that contains a file calledbar/baz
. I would have expected a folder namedbar
with a file namedbaz
.It appears that key names are not getting correctly parsed when inside an absolute parent folder.