Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root Director already exists on Windows #225

Open
dsbert opened this issue Dec 18, 2017 · 2 comments
Open

Root Director already exists on Windows #225

dsbert opened this issue Dec 18, 2017 · 2 comments

Comments

@dsbert
Copy link

dsbert commented Dec 18, 2017

The following is failing on Windows.

    mockfs.restore();
    mockfs(
      {
        "C:\\": {
          "temp.DAT": "original file contents",
          "upload.DAT": "new file contents"
        }
      },
      { createCwd: false }
    );

Results in this error

Item with the same name already exists: \\?\c:

      at Directory.Object.<anonymous>.Directory.addItem (node_modules/mock-fs/lib/directory.js:37:11)
      at populate (node_modules/mock-fs/lib/filesystem.js:160:15)
      at Function.Object.<anonymous>.FileSystem.create (node_modules/mock-fs/lib/filesystem.js:192:5)
      at mock (node_modules/mock-fs/lib/index.js:59:27)
      at Object.test.only (src/handlers/uploadHandler.test.js:131:5)
          at new Promise (<anonymous>)

Also, if I try changing it to this

    const tempPath = `C:\\temp.DAT`;
    const uploadPath = `C:\\upload.DAT`;

    mockfs.restore();
    mockfs({
      [tempPath]: "original file contents",
      [uploadPath]: "new file contents"
    });

    const copyFileAsync = util.promisify(fs.copyFile);
    await copyFileAsync(tempPath, uploadPath);

I end up with the following error;

[Error: ENOENT: no such file or directory, copyfile 'C:\temp.DAT' -> 'C:\upload.DAT']
@guilsa
Copy link

guilsa commented Jul 22, 2018

I'm having the same issue. A bit confused (probably my lack of understanding something).

@guilsa
Copy link

guilsa commented Jul 22, 2018

Ok, the issue was it didn't like the fake path I was using. This works. Before I was using process.cwd() to the path names was colliding.

beforeEach(() => {
  mock({
  'path/to/dir': {
    '07-20-18.txt': 'lets try this',
    }
  });
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants