I followed the docs and keep getting this error:
WARNING in ./~/nock/lib/scope.js
Module not found: Error: Cannot resolve module 'fs' in /<path>/node_modules/nock/lib
@ ./~/nock/lib/scope.js 18:7-20
WARNING in ./~/nock/lib/back.js
Module not found: Error: Cannot resolve module 'fs' in /<path>/node_modules/nock/lib
@ ./~/nock/lib/back.js 17:7-20
ERROR in ./~/mkdirp/index.js
Module not found: Error: Cannot resolve module 'fs' in /<path>/node_modules/mkdirp
@ ./~/mkdirp/index.js 2:9-22
17 12 2015 22:40:41.238:INFO [PhantomJS 1.9.8 (Mac OS X 0.0.0)]: Connected on socket OuFUwRmrq82W5fl8AAAA with id 78948690
PhantomJS 1.9.8 (Mac OS X 0.0.0) ERROR
Error: Cannot find module "fs"
This is probably why: https://github.com/webpack/webpack/issues/689, https://github.com/pgte/nock/issues/409 - so using fetch-mock as alternative
@baopham
You can add
node: {
fs: "empty"
}
into your webpack config.
@choonkending I tried that but it didn't work.
This worked for me (same idea but different code) in your webpack config file.
externals: {
fs: '{}'
},
taken from here https://github.com/request/request/compare/master...pho3nixf1re:webpack-tests
+1 @mario-camacho2 it works for me
+1 @mario-camacho2 works for me too, thank you.
Is nock working for you?
I'm trying to mock axios API calls in redux actions but it hits the real server instead.
@vinceferro nock can't work with karma. Karma launch test in browser and nock works only in node. https://github.com/node-nock/nock/issues/409
Most helpful comment
@baopham
You can add
into your webpack config.