Testing sharp with memfs error: [Error: Input file is missing]
See original GitHub issueI had trouble testing my code that implement sharp
and memfs
. I has codes that download image and cropping it to certain dimension. I use sharp
to achieve the cropping. When it comes testing, I use jest
and memfs
. My test code has 2 parts:
- Download a image and save to mock volume/fileSystem that created with
memfs
. - Cropping the downloaded image to certain dimension with
sharp
.
Part 1 worked perfectly, was able to download image to the fake volume and asserted with jest
(exist in the fake volume).
But part 2 gave me error:[Error: Input file is missing]
.
const sizeToCrop = {
width: 378,
height: 538,
left: 422,
top: 0,
};
sharp(`./downloadedImage.jpg`)
.extract(sizeToCrop)
.toFile(`./CroppedImage.jpg`)
.then(() => {
console.log(`resolve!`);
})
.catch((err: Error) => {
console.log(err);
return Promise.reject();
});
// Error message: [Error: Input file is missing]
But when I test it with real volume. It worked fine.
Anyone has idea how to solve this?
Thank you.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Testing sharp with memfs error: [Error: Input file is missing]
My test code has 2 parts: Download a image and save to mock volume/fileSystem that created with memfs . Cropping the downloaded image...
Read more >Testing sharp with memfs error: [Error: Input file is missing]
I had trouble testing my code that implement sharp and memfs . I has codes that download image and cropping it to certain...
Read more >Error: Input file is missing or of an unsupported image format ...
Hello, This code for image upload and compression works in most cases but some requests fail ((Number of fails increase in load testing) ......
Read more >Testing Sharp With Memfs Error: [Error: Input File Is ... - ADocLib
This error is caused by an unsupported file format or codec or by corrupted Windows Media One or more Windows Media Player files...
Read more >memfs - npm
memfs. In-memory file-system with Node's fs API. Node's fs API implemented, see old API Status, missing list, missing opendir; Stores files ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It looks like
memfs
is a memory-based filesystem, so you’ll probably need to use something like the following:This was helpful. I, however, used
fs