-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
chore(29788): fix code coverage for vitest and cypress (e2e and compo…
…nent)
Showing
10 changed files
with
2,111 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* istanbul ignore file -- @preserve */ | ||
/** | ||
* This script merges the coverage reports from Cypress and Jest into a single one, | ||
* inside the "coverage" folder | ||
*/ | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires,no-undef | ||
const { execSync } = require('child_process') | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires,no-undef | ||
const fs = require('fs-extra') | ||
|
||
const REPORTS_FOLDER = 'reports' | ||
const FINAL_OUTPUT_FOLDER = 'combined-coverage' | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires,no-undef | ||
const { program } = require('commander') | ||
|
||
program | ||
.option('-e --e2e-cov-dir <dir>', 'Directory for e2e coverage', 'e2e/coverage') | ||
.option('-c --ct-cov-dir <dir>', 'Directory for cypress-ct coverage', 'coverage') | ||
.option('-u --unit-cov-dir <dir>', 'Directory for unit test coverage', 'dist/coverage') | ||
|
||
program.parse() | ||
const options = program.opts() | ||
|
||
console.log('Running merge with options:', options) | ||
|
||
const run = (commands) => { | ||
commands.forEach((command) => execSync(command, { stdio: 'inherit' })) | ||
} | ||
|
||
// Create the reports folder and move the reports from cypress and jest inside it | ||
fs.emptyDirSync(REPORTS_FOLDER) | ||
fs.copyFileSync(options.ctCovDir + '/coverage-final.json', `${REPORTS_FOLDER}/from-cypress-ct.json`) | ||
fs.copyFileSync(options.unitCovDir + '/coverage-final.json', `${REPORTS_FOLDER}/from-jest.json`) | ||
|
||
fs.emptyDirSync('.nyc_output') | ||
fs.emptyDirSync(FINAL_OUTPUT_FOLDER) | ||
|
||
// Run "nyc merge" inside the reports folder, merging the two coverage files into one, | ||
// then generate the final report on the coverage folder | ||
run([ | ||
// "nyc merge" will create a "coverage.json" file on the root, we move it to .nyc_output | ||
`npx nyc merge ${REPORTS_FOLDER} && mv coverage.json .nyc_output/out.json`, | ||
`npx nyc report --reporter lcov --report-dir ${FINAL_OUTPUT_FOLDER}`, | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters