question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mock-fs compatibility

See original GitHub issue

Environment

  • OS Version: macOS 10.13.3
  • Node.js Version: 8.9.4

Actual behavior

I’ve written a gulp-like file transformer to glob for files, read them, modify them, and write them back to the file system. I’ve also included delete functionality. As this functionality can be highly dangerous when there’s a bug, I test using mock-fs.

I had been using globby, but switched to using fast-glob directly. When I was using globby v7 (backed by node-glob) I was able to use mock-fs. Now, using fast-glob, I get ENOENT errors thrown.

Expected behavior

Allow file-system to be mocked for testing using something like mock-fs or by passing a mock file system object to fast-glob as an option.

Steps to reproduce

  1. git clone https://github.com/shannonmoeller/ygor.git
  2. cd ygor
  3. npm it

Sample Code

https://github.com/shannonmoeller/ygor/blob/bcf063038fbecb7279468dbd32eecb44322d5e30/packages/files/test/files.js#L12

image

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jonschlinkertcommented, Mar 11, 2018

nvm, it may well have been a change in mock-fs but I went ahead and bumped the use package in snapdragon and published 0.8.2 with that change. You will need to reinstall everything and to make sure NPM uses that version you’ll also need to delete package-lock.json files.

0reactions
shannonmoellercommented, Mar 12, 2018

Confirming this update fixed the issue. Thanks again!

Read more comments on GitHub >

github_iconTop Results From Across the Web

mock-fs - npm
A configurable mock file system. You know, for testing.. Latest version: 5.2.0, last published: 2 months ago. Start using mock-fs in your ...
Read more >
tschaub/mock-fs: Configurable mock for the fs module - GitHub
Note mock-fs is not compatible with graceful-fs@3.x but works with graceful-fs@4.x . Mock file access is controlled based on file mode where process.getuid() ......
Read more >
node_modules/mock-fs - GitLab
The mock-fs module allows Node's built-in fs module to be backed ... Note mock-fs is not compatible with graceful-fs@3.x but works with ...
Read more >
Unit testing Node.js fs with mock-fs - Emma Goto
In this post I'll be showing you how you can use mock-fs to easily unit test your Node.js scripts. If you want to...
Read more >
pyfakefs - PyPI
Compatibility. pyfakefs works with CPython 3.7 and above, on Linux, Windows and macOS, and with PyPy3. pyfakefs works with pytest version 3.0.0 or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found