dimanche 29 mai 2016

Node Mock-fs - /path/to/file is not being mocked

Unit testing my gulp app in Mocha and using mock-fs from mock-fs repo .

In my app code I have:

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

which shows sssssssssssssss /home/one/foo

In my test I have:

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

But I get the error Error: ENOENT, no such file or directory '/home/one/foo' when I run the test.

What I am doing wrong where /home/one/foo is not being mocked?

Aucun commentaire:

Enregistrer un commentaire