wegue-oss / wegue

Template and components for webmapping applications with OpenLayers and Vue.js
BSD 2-Clause "Simplified" License
93 stars 41 forks source link

Avoid dist directory cluttering when running unit tests #398

Closed sronveaux closed 1 month ago

sronveaux commented 1 month ago

This PR changes the configuration in vue.config.js when in test mode to avoid an unsuitable behaviour introduced, apparently, when updating to Vue-CLI 3...

For now, when you run the unit tests, karma-webpack outputs the results in the dist directory, potentially destroying your latest build and adding some files only related to tests (common.js and runtime.js).

The reason is that when Vue-CLI 2 was used, Karma was one of the test runners recommended by Vue, so configuration was adapted for it. If you go back in time, you'll see that webpack configuration was almost empty in test mode compared to dev mode.
In Vue-CLI, the recommended test runner was mochapack which works completely differently. But most important, as stated in their documentation, it is written in a way that nothing is ever written on the disk by webpack, all stays is memory.

So there are two tweaks made by this PR in the config file:

  1. Remove the unneeded plugins from webpack configuration in order to behave closer to like it was in Vue-CLI 2
  2. Remove the config.output.path so default value of karma-webpack is taken, effectively outputting the build inside a temporary directory