I have issue, which is detailed below; please take a look.
In nuxt.config.ts , I have this code
plugins: [
istanbul({
exclude: ['node_modules', 'test/', 'coverage/', 'cypress/'],
extension: ['.js', '.ts', '.vue'],
cypress: true,
forceBuildInstrument: process.env.CYPRESS_ENV === 'github_action'
})
]
},
So, in the above condition, if I remove forceBuildInstrument, the coverage report is not generted but if I make forceBuildInstrument true, it generates a report, but there is one problem: the AWS CI check failed in github action , so to avoid this, I create a condition that only makes it true for github actions and false for AWS production environments.
additionally previous I used NODE ENV instead of CYPRESS ENV here, but in github action check bydefault cypress convert NODE ENV ‘github_action’ to production, which fails the code coverage, so I used CYPRESS ENV here so, to create a separate environment for running cypress tests.
In CI.yml
- name: Checkout the code
uses: actions/checkout@v3
- name: Cypress run
uses: cypress-io/github-action@v5
env:
NODE_OPTIONS: "--max_old_space_size=4096"
CYPRESS_ENV: github_action
with:
start: npm run preview
wait-on: 'http://localhost:3000'
browser: chrome
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage
fail_ci_if_error: true
env:
CYPRESS_RECORD_KEY: "d0d2b93e-e596-4468-9fd9-df533f9c2c2c" # TODO: hide this
BACKEND_URL: http://localhost:3001/
After a successful test, it generates a report in github that looks like this:
Codecov Report
No coverage uploaded for pull request base (master@30e4697). Click here to learn what that means.
Patch has no changes to coverable lines.
Additional details and impacted files
@@ Coverage Diff @@
master #220 +/-
=========================================
Coverage ? 59.82%
Files ? 182
Lines ? 5396
Branches ? 1015
Hits ? 3228
Misses ? 2165
Partials ? 3
However, the cypress code coverage report has now been generated by iT, but in the codecov account, it shown an missing base commit , also in frontend it shows no data available on codecov .