Closed misantronic closed 8 years ago
Looks like you are sharing your webpack config between karma:unit
and 'webpack:build'
grunt tasks, but I can't tell how without seeing the whole setup. Just make sure that your build config doesn't contain isparta in preLoaders
section.
Thanks for your reply. I took care of not sharing the webpack-config in the task but cloning them:
So in my karma setup I do
var webpackConfig = _.extend(
{},
require('./webpack.config'),
{
plugins: [
...
]
}
);
// instrument only testing sources with Istanbul
webpackConfig.module.preLoaders = [
{
test: /\.js$/,
include: path.resolve('app/'),
loader: 'istanbul-instrumenter'
}
];
Is it possible, that the preloader caches something for later use?
istanbul-instrumenter
uses only internal webpack cache within one run... very strange.
It actually did share the preLoader between the tasks - although I did clone it. Quite strange.
I fixed it by adding a task before webpack:build
which removes the instrumenter from the preLoaders:
grunt.task.registerTask('removeInstrumenter', 'Removes instanbul-instrumenter from webpack preloaders', function () {
webpackConfig.module.preLoaders = _.filter(webpackConfig.module.preLoaders, function (loaderObj) {
return loaderObj.loader !== 'istanbul-instrumenter'
});
});
I generate my build with grunt. The task look like this:
So what happens is that all tests run and for coverage-support I add the instrumenter as a preLoader:
This works fine for me. So far, so good. After this task finished and
webpack:build
is running, in which the preLoader is not even preset, the compiled source still shows the coverage likeThis will not happen if I never add the instrumenter as a preLoader. Why is it still present in my build task even though the webpack.config does not contain it?