Module not found: 'rewiremock/webpack/interceptor'
hirikarate opened this issue ยท 1 comments
hirikarate commented
I added this line of code according to the documentation
import 'rewiremock/webpack/interceptor';but had this error when running webpack to test my NodeJS app:
Module not found: 'rewiremock/webpack/interceptor
This if my app.spec.js:
import 'rewiremock/webpack/interceptor';
import rewiremock from 'rewiremock/webpack';
rewiremock
.proxy('square-connect', (r) => ({
'callMe': () => console.log('-------------MOCK---------------'),
}))
.toBeUsed();
rewiremock.enable();
import * as SquareConnect from 'square-connect';
console.log('--------MOCKED: ', typeof SquareConnect.callMe);
rewiremock.disable();I already added 3 plugins to my test webpack.config.js:
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new RewiremockWebpackPlugin(), // which is require("rewiremock/webpack/plugin")My dependencies:
- "rewiremock": "3.14.3"
- "webpack" ""4.43.0"
- NodeJS v.12
Thank you!
theKashey commented
I should have updated documentation ๐
Well, almost 2 years ago ๐
You don't have to include interceptor anymore.