首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gitlab测试覆盖率可视化不起作用

Gitlab测试覆盖率可视化不起作用
EN

Stack Overflow用户
提问于 2021-03-15 13:53:15
回答 1查看 2.9K关注 0票数 8

大家好,我有一个快速的应用程序,我正在使用gitlab来添加Gitlab test coverage visualization

这是我的.gitlab-ci.yml

代码语言:javascript
复制
stages:
  - test
  - dockerize
  - staging
  - production

unit-tests:
  stage: test
  script:
    - npm install
    - npm run test
    - npm run test-coverage
    - cat coverage/cobertura-coverage.xml
    - "echo 'Code coverage: 90.90'" 
  coverage: '/Code coverage: \d+\.\d+/'
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
    - if: '$CI_COMMIT_BRANCH == "master"'
    - if: '$CI_COMMIT_BRANCH == "release-v1"'
  artifacts:
    reports:
      cobertura: coverage/cobertura-coverage.xml
  tags:
   - demo

dockerize-application:
  stage: dockerize
  script:
    - echo "dockerizing application"
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
    - if: '$CI_COMMIT_BRANCH == "master"'
    - if: '$CI_COMMIT_BRANCH == "release-v1"'
  tags:
   - demo


deploy_to_staging:
  stage: staging
  script:
    - echo "deploying to staging"
  rules:
    - if: '$CI_COMMIT_BRANCH == "master"'
  tags:
   - demo

deploy_to_production:
  stage: staging
  script:
    - echo "deploying to production"
  rules:
    - if: '$CI_COMMIT_BRANCH == "release-v1"'
  tags:
   - demo

在我的包json中,这里是重要的部分:

代码语言:javascript
复制
"scripts": {
    "start": "node ./bin/www",
    "debug": "nodemon ./bin/www",
    "test": "npx nyc --reporter text mocha",
    "test-coverage": "npx nyc --reporter cobertura mocha"
  }

在日志中,我可以看到coverage文件已上载。

代码语言:javascript
复制
Runtime platform                                    arch=amd64 os=windows pid=19548 revision=775dd39d version=13.8.0
coverage/cobertura-coverage.xml: found 1 matching files and directories 
Uploading artifacts as "cobertura" to coordinator... ok  id=1097622443 responseStatus=201 Created token=6wcrN_d_

我做了很多研究,但我还是不明白为什么!我认为这是一个默认情况下关闭此功能的功能标志,但不再是这样:

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/43711

这是我的项目的link:我创建它主要是为了试验gitlab ci/cd

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-25 13:32:23

它现在可以工作了。问题是,我需要等待整个管道成功,才能真正看到可视化效果。

以下是Gitlab中的一个公开问题:

https://gitlab.com/gitlab-org/gitlab/-/issues/236248

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66632969

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档