Add Testing to Existing Vue Project
So having the project already started which in hindsight I should document but as this is adding to an existing project I guess this will be the starting point. Using the vue-cli you can add testing to a project as follows:
vue add @vue/unit-jest
That will add the testing suite to your project and even include an example of a test. My one change to it was in the
package.json file scripts to add watch to the testing script so that I don't have to run it every time but it rather act's as a runner.
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit --watch",
"lint": "vue-cli-service lint"
Now when using VS Code I have a split terminal. One running the
serve script and the other running
test:unit. I might even delete the
:unit for now as this project might only use unit tests.