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.

Possible to use Jimp with mock-fs?

See original GitHub issue

I’m using mock-fs to test my project and if I try to include a serialised image byte array as a fixture:

https://github.com/edsilv/biiif/blob/thumbs/test/top.js#L159

Jimp.read throws this error:

Error: ENOENT, no such file or directory '\\?\c:\Users\edsilv\github\edsilv\biiif\generate-thumbs-manifest\_canvas-without-thumb\file.jpg'
Utils.js:140
unable to generate thumbnail for: c:\generate-thumbs-manifest\_canvas-without-thumb

Other yml fixtures are being read by js-yaml’s safeLoad. Is Jimp able to work with a mocked filesystem?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
edsilvcommented, Sep 15, 2018

Hi, just having another look at this.

/cat/cat.jpg passes.

c:\cat\cat.jpg throws

ENOENT, no such file or directory ‘\?\c:\Users\edsilv\github\edsilv\jimp-mock-fs-error-demo\catcat.jpg’

“catcat.jpg” - It was to do with using windows backslashes in file paths. Once I normalised these to using forward slashes it started working 😃

1reaction
edsilvcommented, Sep 1, 2018

Hi, sorry for the delay. Here’s an example project:

https://github.com/edsilv/jimp-mock-fs-error-demo

Annoyingly I can’t install Jimp to test this locally right now because of https://status.npmjs.org/incidents/v22ffls5cd6h - but it should be what you need.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Image processing with Node and Jimp - LogRocket Blog
In this tutorial, we'll go over how the library works and describe some common use cases for Jimp image manipulation.
Read more >
mock-fs - npm
Start using mock-fs in your project by running `npm i mock-fs`. There are 150 other projects in the npm registry using mock-fs.
Read more >
Node.js testing: Using a virtual filesystem as a mock
The mock-fs module streamlines this by letting you provide a simple mapping of paths to file contents and it mostly works.
Read more >
Image Processing in Node.js with Jimp - YouTube
In this video, I will be showing you the powerful library Jimp for image manipulation in Node.js Subscribe for more ...
Read more >
Unit testing Node.js fs with mock-fs - Emma Goto
Mock your files and folders using mock-fs. We want to be able to mock out some files, because otherwise you would need to...
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