Node mock-fs library - /path/to/file is not being mocked

513 Views Asked by At

Unit testing my gulp app in Mocha and using mock-fs from the 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 following error when running the test:

Error: ENOENT, no such file or directory '/home/one/foo'

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

0

There are 0 best solutions below