节点Mock-fs – / path / to / file不被模拟

在Mochaunit testing我的吞噬应用程序,并使用mock-fs回购模拟fs 。

在我的应用程序代码中,我有:

 console.log('sssssssssssssss ' + srcFile); srcFile = fs.statSync(srcFile).mtime; 

其中显示了sssssssssssssss /home/one/foo

在我的testing中,我有:

  mock({ home: { one: { foo: mock.file({ content: 'nothing', mtime: new Date(Date.now()) }) }, }, bar: mock.file({ content: 'nothing', mtime: new Date(1,1) }) }); 

但是当我运行testing时Error: ENOENT, no such file or directory '/home/one/foo'出现Error: ENOENT, no such file or directory '/home/one/foo'

我在做什么错在/home/one/foo没有被模拟?