Cobertura coverage not showing in diff or jobs

An issue that I ran into with this was that I hadn’t merged the MR which adds coverage into the main branch. You probably have done this already, but if you haven’t then the MR diffs won’t show up until this job has been merged in.

Yes, I have done this already. My main branch already has the gitlab ci. I also have updated it to the following so I can see the coverage statistics in the analysis section. but it does not seem to show

# .gitlab-ci.yml

image: node:12

# Define the stages of the pipeline
stages:
  - test

cache:
  paths:
    - node_modules/

# Define the job that will run tests
test:
  stage: test
  script:
    - npm install
    - npm run test -- --coverage --verbose
  artifacts:
    when: always
    paths:
      - junit.xml
      - coverage/cobertura-coverage.xml
    reports:
      coverage_report:
        coverage_format: cobertura
        path: coverage/cobertura-coverage.xml
      junit: junit.xml
  # Add coverage to code coverage statistics
  coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'

  # Define when this job should be executed
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"'


I have the problem when trying to combine the functionalities of “Test coverage visualization” (coverage_report) and “View Code Coverage results” (coverage) within the same job in GitLab CI/CD.

When I configure the pipeline like this:

run_tests_and_analyze:
  extends:
    - .linux_android_saas_runners
    - .use_cache
  stage: test_and_analyze
  artifacts:
    when: always
    reports:
      coverage_report:
        coverage_format: cobertura
        path: coverage/cobertura.xml
  coverage: '/lines\.{6}: (\d+(?:\.\d+)?)%/'

Only the “View Code Coverage results” (coverage) functionality works, while the “Test coverage visualization” (coverage_report) is ignored.

If I remove the coverage key, like this:

run_tests_and_analyze:
  extends:
    - .linux_android_saas_runners
    - .use_cache
  stage: test_and_analyze
  artifacts:
    when: always
    reports:
      coverage_report:
        coverage_format: cobertura
        path: coverage/cobertura.xml

The “Test coverage visualization” (coverage_report) works correctly, but I lose the overall code coverage view.

Similarly, if I configure only coverage, only the “View Code Coverage results” functionality works, but without the detailed visualization.

What I expected was:

  1. When both coverage_report and coverage are configured in the same job, both functionalities should work correctly, meaning:
  • “Test coverage visualization” (coverage_report)
  • “View Code Coverage results” (coverage)
  1. Additionally, when coverage_report is used alone, GitLab should be able to capture and display the total coverage directly from the cobertura.xml file without requiring a regex in the pipeline.

It would be helpful to combine these features for better coverage visibility. Is there a workaround or plans to support both functionalities together?