- Operating System: macOS Big Sur v11.2.1
- Node Version: 15.10.0
- NPM Version: 7.5.3
- webpack Version: 5.24.2
- karma-webpack Version: 5.0.0
Expected Behavior
I have a number of SVG, PDF, JS workers, and other files in my webpack app. Obviously, it works all good while running the app normally, but when I get to run my mocha test with karma-webpack some of my tests fail due to failures with loading those mentioned asset-like files
Code
// webpack.config.js
{
test: /\.(png|svg)$/,
include: [resolve(__dirname, 'app', 'assets')],
type: 'asset/resource',
generator: {
filename: 'images/[name][ext]',
},
},
So when I run via command line I see errors like:
404: /absolute/var/folders/qm/dx__qpt10rnd8rg2st400l200000gp/T/_karma_webpack_117318/f2462e1d0c87e9b2fd42.worker.js
404: /absolute/var/folders/qm/dx__qpt10rnd8rg2st400l200000gp/T/_karma_webpack_117318/images/logo-black-trademark.svg
I run it using browser to see what's going on in Dev Tools, and see the same results:

So when I got curious to see what's in the _karma_webpack_117318 folder, where I assumed it keeps my webpack assets. I found it in my macOS and indeed files are there:

So these files commons.js and runtime.js are loaded just fine, but not my files. This makes me think that when the browser does GET http://localhost:9876/absolute/var/folders/qm/dx__qpt10rnd8rg2st400l200000gp/T/_karma_webpack_117318/runtime.js it does not directly point to the disk folder. I made a test, by adding few lines of code into runtime.js to see if it will show up in the browser. It didn't. So I guess there is another memory cache or storage is used to serve the browser.
Maybe the state of _karma_webpack_117318 folder was cached before webpack finished the build, so my assets weren't cached in time and hence aren't served to browser?
The general question is... Is this a karma-webpack bug? Or did I miss some config?
Expected Behavior
I have a number of SVG, PDF, JS workers, and other files in my webpack app. Obviously, it works all good while running the app normally, but when I get to run my mocha test with karma-webpack some of my tests fail due to failures with loading those mentioned asset-like files
Code
So when I run via command line I see errors like:
I run it using browser to see what's going on in Dev Tools, and see the same results:

So when I got curious to see what's in the
_karma_webpack_117318folder, where I assumed it keeps my webpack assets. I found it in my macOS and indeed files are there:So these files
commons.jsandruntime.jsare loaded just fine, but not my files. This makes me think that when the browser doesGET http://localhost:9876/absolute/var/folders/qm/dx__qpt10rnd8rg2st400l200000gp/T/_karma_webpack_117318/runtime.jsit does not directly point to the disk folder. I made a test, by adding few lines of code intoruntime.jsto see if it will show up in the browser. It didn't. So I guess there is another memory cache or storage is used to serve the browser.Maybe the state of
_karma_webpack_117318folder was cached before webpack finished the build, so my assets weren't cached in time and hence aren't served to browser?The general question is... Is this a karma-webpack bug? Or did I miss some config?