You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using mock-fs with supertest to test file uploads in an express application. I get hit with Error: ENOENT, no such file or directory messages from the endpoint, though in the context of the test the file is definitely present.
Error: ENOENT, no such file or directory 'public/images/c92a0180e347a9730417596326f3d166'
at Binding.<anonymous> (mock-fs-supertest-express-example/node_modules/mock-fs/lib/binding.js:287:15)
at maybeCallback (mock-fs-supertest-express-example/node_modules/mock-fs/lib/binding.js:27:18)
at Binding.open (mock-fs-supertest-express-example/node_modules/mock-fs/lib/binding.js:274:10)
at Object.fs.open (mock-fs-supertest-express-example/node_modules/mock-fs/node/fs-0.12.0.js:493:11)
at WriteStream.open (mock-fs-supertest-express-example/node_modules/mock-fs/node/fs-0.12.0.js:1774:6)
at new WriteStream (mock-fs-supertest-express-example/node_modules/mock-fs/node/fs-0.12.0.js:1764:10)
at Object.fs.createWriteStream (mock-fs-supertest-express-example/node_modules/mock-fs/node/fs-0.12.0.js:1728:10)
at mock-fs-supertest-express-example/node_modules/multer/storage/disk.js:38:26
at Object.ondone (mock-fs-supertest-express-example/node_modules/multer/storage/disk.js:9:5)
I feel like I'm missing something fairly obvious (perhaps I just need to spy on the writing of the temporary file and return the same value?) though I'm unsure of the answer. Apologies if this turns out to not be directly to issues with mock-fs itself. I have working tests for actual files, but swapping out the large image file with a mocked file fails.
I will gladly contribute an idiots guide/express example PR if I can make sense of it, as I imagine this will be a fairly common use case for the library.
The text was updated successfully, but these errors were encountered:
I'm using
mock-fs
with supertest to test file uploads in an express application. I get hit withError: ENOENT, no such file or directory
messages from the endpoint, though in the context of the test the file is definitely present.I've made a sample of my problem here: https://github.com/roc/mock-fs-supertest-express-example
Example response:
I feel like I'm missing something fairly obvious (perhaps I just need to spy on the writing of the temporary file and return the same value?) though I'm unsure of the answer. Apologies if this turns out to not be directly to issues with
mock-fs
itself. I have working tests for actual files, but swapping out the large image file with a mocked file fails.I will gladly contribute an idiots guide/express example PR if I can make sense of it, as I imagine this will be a fairly common use case for the library.
The text was updated successfully, but these errors were encountered: