March 2018
Beginner to intermediate
344 pages
7h 7m
English
We covered testing our Vue.js applications in the preceding chapter, so wouldn't it be nice to automatically run our tests each time we push a new build? Let's quickly set up some tests inside of our project and integrate it with Travis:
# Install necessary dependencies$ npm install jest vue-test-utils babel-jest vue-jest --save-dev
We can then add a new script that runs jest:
{ "scripts": { "test": "jest" }}
Next, add the jest configuration to your package.json:
"jest": { "moduleNameMapper": { "^@/(.*)$": "<rootDir>/src/$1" }, "moduleFileExtensions": [ "js", "vue" ], "transform": { "^.+\\.js$": "<rootDir>/node_modules/babel-jest", ".*\\.(vue)$": "<rootDir>/node_modules/vue-jest" }}
Finally, we can update our babel configuration ...
Read now
Unlock full access