I am trying to run a unit test with coverage (using karma-coverage ) and webpack (using karma-webpack ). Tests run as expected, but in order to generate a coverage report, the actual source file (not the test) must be downloaded and passed through the coverage and webpack .
Unfortunately, this fails with the following error:
ERROR [karma]: { [Error: no such file or directory] code: 'ENOENT', errno: 34, message: 'no such file or directory', path: '/_karma_webpack_/views/Foo/Foo.js' } Error: no such file or directory
Foo.js is a file containing the source. The directory structure is as follows:
karma.conf.js - src/ - js/ - views/ - Foo/ - Foo.js - test/ - FooTest.js
karma.conf.js :
module.exports = function (config) { config.set({ basePath: 'src/js/', frameworks: ['jasmine'], files: [ '**/test/*Test.js', '**/Foo.js', ], exclude: [], preprocessors: { '**/test/*Test.js': ['webpack'], '**/Foo.js': ['webpack', 'coverage'], }, coverageReporter: { type: 'html', dir: 'coverage', }, webpack: { resolve: { alias: [ { _karma_webpack_: 'src/js' }, ], }, }, reporters: ['progress', 'coverage'], port: 9876, colors: true, logLevel: config.LOG_DEBUG, autoWatch: true, browsers: ['Chrome'], singleRun: false, concurrency: Infinity, }); };
The problem is obvious: the path /_karma_webpack_/views/Foo/Foo.js really does not exist. I guess this is some kind of inner path, but how can I change that?
As you can see, I already tried to use the web package permission setting for this, but it does not work. Since the error message indicates ERROR [karma] , I am also a little worried that this error may be something else.
In addition, I had a suspicion that the globbing **/Foo.js template might have **/Foo.js turned off, but trying to make some changes there (e.g. **/**/Foo.js ) did not help either.