code-coverage
code-coverage copied to clipboard
Set `defaultNycOptions` via environment variables.
Is your feature request related to a problem? Please describe.
I am running my Cypress tests in parallel via GitHub Actions, on multiple VMs.
I want each tests coverage to be written to a different directory so that they may later be merged.
The report-dir for NYC therefore needs to differ for each parallelized test.
This repo only supports a static value for report-dir as defined as code in the NYC config..
I would like for the report-dir value to be variable and set at runtime by the GitHub Action.
Describe the solution you'd like
In common-utils.js, the report-dir property should be set to something like process.env.CYPRESS_REPORT_DIR || './coverage', allowing me to set the CYPRESS_REPORT_DIR environment variable for each parallelized test in the action.
Describe alternatives you've considered
Adding a step to the action that writes a second NYC file (e.g. YAML) or overrides the JSON NYC config to set the report-dir manually, but I'm pretty opposed to having such manual script management in my actions when it can be abstracted here.
I've unblocked myself by converting my NYC config file from JSON to JS and referencing process.env there, but I don't like the repetition here: my NYC config references NYC_REPORT_DIR while my Cypress plugin file sets NYC_REPORT_DIR. I'm still having to manage an environment variable in code that could (should?) be abstracted away via native support.