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
in test files (preprocessor, beforeEach or whatever) but when you use superagent-mock in a client app (running in the browser), you had to append these lines somewhere in your source files.
new webpack.DefinePlugin({
...
__IS_MOCKED__: JSON.stringify(argv.env.mock),
}),
And inside my src/index.js:
if(__IS_MOCKED__) {
require('./mocks');
}
The mocks folder index file will have the mock configuration together with superagent-mock require.
The uglification process will remove it from the production build (provided no --env.mock was added to its build script)
It's okay to write these two lines of code
in test files (preprocessor, beforeEach or whatever) but when you use superagent-mock in a client app (running in the browser), you had to append these lines somewhere in your source files.
How about a webpack loader (a postLoader I think) ?
I'm not a webpack expert but I think it could do the job and keep your sources clean 🤘
The text was updated successfully, but these errors were encountered: