This shows a "bug" within karma-webpack when used with global variabels / e.g. custom elements registry.
Each test file get's bundled individually but placed in a single browser window.
- foo-one has a test file
- load bundle one
- foo-one gets registered
- all good
- foo-two has a test file
- load bundle two
- has a has a dependency on foo-one
- foo one is included (again) in bundle (as bundles are created in isolation)
- => ERROR
Failed to execute 'define' on 'CustomElementRegistry': this name has already been used with this registry
npm install
npm run test
These are mere ideas to spark a conversation:
Besides the *.test.js files have also an index.js
Good
- easily doable
- no change in karma-webpack needed
Bad
- can't load individual test files
- cumbersome => need to add file + add to index.js
- not really sadisfying Developer Experience
Use https://webpack.js.org/concepts/entry-points/#multi-page-application to create bundles that know of each other. E.g. do not create bundles in isolation.
Good
- easy
- can load individual test files
- just "works" and therfore sadisfying Developer Experience
- smaller test bundles
Bad
- change in karma-webpack needed