简体   繁体   English

如何在 Angular GitHub + TravisCI 项目中设置工作服

[英]How to set up coveralls in an Angular GitHub + TravisCI project

In my Angular project hosted on GitHub, I'm running the tests in TravisCI using:在我托管在 GitHub 上的 Angular 项目中,我使用以下方法在 TravisCI 中运行测试:

package.json scripts package.json 脚本

 "test-ci": "ng test --watch=false"

.travis.yml script .travis.yml 脚本

script:
  - ng lint
  - npm run test-ci
  - npm run e2e
  - npm run build

I would like to set up coveralls , however from the official documentation and articles on the web it is not super clear what I have to do.我想设置工作服,但是从官方文档和网络上的文章来看,我必须做什么并不是很清楚。

I solved by simply using node-coveralls .我通过简单地使用node-coveralls来解决。

What I had to do was just installing it:我所要做的就是安装它:

npm install coveralls --save-dev

And then in my package.json scripts change:然后在我的package.json脚本中更改:

 "test-ci": "ng test --watch=false"

to:到:

 "test-ci": "ng test --watch=false --code-coverage && cat ./coverage/lcov.info | coveralls"

While I do like what @Francesco Borzi mentioned but keeping ci in mind I think we need to do it in two steps, you don't have to publish this for a pull request unless its a success.虽然我确实喜欢@Francesco Borzi提到的内容,但请记住,我认为我们需要分两步完成,除非成功,否则您不必为拉取请求发布此内容。 You could fail the build你可能会失败构建

  1. run the test as part of the initial step作为初始步骤的一部分运行测试
  2. publish the output from the above step to coveralls将上述步骤的输出发布到工作服

script: - ng test --watch=false after_success: - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM