Closed DanielSchaffer closed 10 months ago
Update - I was able to work around this by disabling the chunking in my Webpack configuration:
optimization: {
splitChunks: false,
},
As karma is now deprecated and coming up on EOL, we are no longer planning on any significant enhancements to this project and are instead going to focus on security updates, stability, and a migration path forward as karma's lifecycle comes to an end.
Thank you for supporting and using this project!
Expected Behavior
The actual relative path to the source file appears in the source paths shown in stack traces.
Actual Behavior
The source path includes the temp directory used by
karma-webpack
, as well as awebpack:
prefix (e.g./var/folders/q1/s7h94rm52tg13mgk63qyl06c0000gn/T/_karma_webpack_361378/webpack:
)How Do We Reproduce?
See repro in this repository: https://github.com/DanielSchaffer/karma-webpack-source-path-repro
Run
yarn
and thenyarn test
.Notes
My repro uses a single "bundle" approach rather than including each test file separately. There are two reasons for this - first, it allows the coverage report to include source files even if they aren't referenced via a test, which is important to be able to find source files that are completely untested. More importantly, the separate file approach has a significant amount of performance overhead with anything other than very small projects due to the difference in how Webpack ends up getting used for compilation.
When debugging, I tried manually setting my own
output.path
in the Webpack config, and then setting karma'surlRoot
config to the same value - this produced the correct source paths, but it also broke something that prevented Karma'sdebug.html
from being served.A possible approach to fixing this may be finding a way to include the commons and runtime files referenced in
lib/karma-webpack/framework.js
without requiring Webpack's output path to be configured - possibly by using the same temp path but without setting that path in the Webpack configuration.