How to run an ng test before running ng -prod and jenkins fail if ng fails?

I used to use the angular-cli systemJS version, and whenever I used the kick from jenkins command, the build was used to fail if a test case failed.

I just had the ng build --prod to create my project.

Now, using the webpack version of angular-cli, we must explicitly run ng test .

How can I check jenkins if ng test able to run and continue with ng build --prod , or did the build fail?

+6
source share
1 answer

You can create an npm script, as shown below, to abandon the build if tests fail:

 "scripts" : { "cibuild": "ng test --code-coverage && ng build --prod --no-progress" } 

The above assumes that you have singleRun: true in the karma.conf.js file. Then you can run npm run cibuild , which will run the tests first, and then build only if the tests pass. We use this for our CI assembly through Jenkins and then scanning the sonar.

+2
source

Source: https://habr.com/ru/post/1011924/


All Articles