Mochawesome Report Generator is generating old reports only

24 views Asked by At

I'm setting up a GitLab pipeline for my Cypress tests, and I'm encountering an issue where old Mochawesome report files persist even after removing them from the artifacts directory. I want to ensure that newly generated Mochawesome report files are properly merged in the pipeline.

Here's a simplified version of my GitLab CI configuration:

# first, install Cypress, then run all tests
stages:
  - build
  - test
  - pages

# to cache both npm modules and Cypress binary we use environment variables
# to point at the folders we can list as paths in "cache" job settings
variables:
  npm_config_cache: "$CI_PROJECT_DIR/.npm"
  CYPRESS_CACHE_FOLDER: "$CI_PROJECT_DIR/cache/Cypress"

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - .npm
    - cache/Cypress
    - node_modules

# this job installs NPM dependencies and Cypress
install:
  image: cypress/browsers:node18.12.0-chrome106-ff106
  stage: build
  script:
    - npm ci
    # check Cypress binary path and cached versions
    # useful to make sure we are not carrying around old versions
    - npx cypress cache path
    - npx cypress cache list
    - npm run cy:verify
    - npm run cy:info

test:
  image: cypress/browsers:node18.12.0-chrome106-ff106
  stage: test
  parallel: 7
  script:
  
    # Run cypress tests
    - npx cypress run --record --key MY Key --parallel --reporter mochawesome  --reporter-options reportDir=mochawesome-report,overwrite=false,html=false,json=true
  artifacts:
    expire_in: 30 days
    when: always
    paths:
      - mochawesome-report
      - cypress/screenshots

pages:
  image: cypress/browsers:node18.12.0-chrome106-ff106
  stage: pages
  script:
    # Generate Mochawesome report
    - npx mochawesome-merge "mochawesome-report/*.json" > mochawesome.json
    - npx marge mochawesome.json
    # Rename mochawesome-report folder to public
    - mv mochawesome-report public
  when: always
  artifacts:
    expire_in: 30 days
    when: always
    paths:
      - public
      - mochawesome-report

Despite removing old report files, they continue to appear when viewing the artifacts. How can I ensure that only newly generated Mochawesome report files are merged in the pipeline, and old reports are not retained?

I appreciate any insights or suggestions on resolving this issue. Thank you!

0

There are 0 answers