Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

waleedKasem's avatar

Multiple assets emit to the same filename bundle.js

when i try to run mocha using laravel mix it gives me this error

Conflict: Multiple assets emit to the same filename bundle.js

how can i fix this with laravel mix ?

this is the command i am running

mocha-webpack --webpack-config=node_modules/laravel-mix/setup/webpack.config.js --require tests/Javascript/setup.js tests/Javascript/*/.spec.js

0 likes
3 replies
Mithrandir's avatar

Same here - I am really unsure how to get started with mocha-webpack testing a Vue application using laravel mix.

I can get the most basic tests running with just a webpack config file to use vue-loader on .vue files, but as soon as I need something more, I run into problems and assume I have to load the same webpack configuration as the dev/production builds - but how?

Mithrandir's avatar

I found that if I use mix.extract() it will fail with this message. By adding a cross-env NODE_ENV=testing and testing for this environment in the mix config file, I can make this only run in non-testing environments - and the error is dispersed.

2 likes
shadrix's avatar

Just to add to Mithrandir, your package.json looks for example like this:

"test": "cross-env NODE_ENV=testing mocha-webpack --webpack-config=node_modules/laravel-mix/setup/webpack.config.js --require tests/Vue/setup.js tests/Vue/\\*\\*/\\*.spec.js",

And in webpack

if (process.env.NODE_ENV !== 'testing') {
    mix.extract(); 
}

Please or to participate in this conversation.