I am currently working on the task “Implement code coverage feature for Component Tests”. The coverage report is generated successfully in the local environment; however, the same report is not being generated on Jenkins. On Jenkins, I am only able to see the bundled files — the processed coverage reports are missing.
✅ Local Result
Coverage report is generated successfully.
Coverage files and summary reports are visible.
❌ Jenkins Result
Only bundle files are generated.
Coverage summary and processed coverage reports are not produced.
Configuration Used:
- Coverage Setup in browser-manager.ts
public static async startJSCoverage() {
console.log('!!! Starting JS !!!');
await this.page.coverage.startJSCoverage();
}
public static async stopJSCoverage() {
console.log('!!! Stopping JS !!!');
const jsCoverage = await this.page.coverage.stopJSCoverage();
console.log('!!! JS Coverage Collected:', jsCoverage.length > 0 ? jsCoverage : 'No JS coverage data.');
return jsCoverage;
}
// Generate coverage files
public static async generateCoverageFiles(): Promise {
const coverage = await this.stopJSCoverage();
if (!coverage.length) {
console.log('No coverage data was collected.');
return;
}
// Ensure coverage directory exists
fs.mkdirSync('coverage', { recursive: true });
// Save coverage data as JavaScript file
const fullCoverageJSPath = path.resolve('coverage', 'coverage.js');
const jsContent = const coverageData = ${JSON.stringify(coverage, null, 2)};;
fs.writeFileSync(fullCoverageJSPath, jsContent, 'utf-8');
console.log(Coverage data saved at: ${fullCoverageJSPath});
const processCoverageFile = async (fileCoverage: any, fileIdentifier: string) => {
if (!fileCoverage) {
console.log(${fileIdentifier} coverage not found.);
return;
}
const filePath = path.resolve('coverage', `${fileIdentifier}.json`); try { const converter = v8toIstanbul(filePath, 0, { source: fileCoverage.source }); await converter.load(); converter.applyCoverage(fileCoverage.functions); const istanbulCoverage = converter.toIstanbul(); fs.writeFileSync(filePath, JSON.stringify(istanbulCoverage, null, 2), 'utf-8'); console.log(`Coverage report saved at: ${filePath}`); const jsFilePath = filePath.replace('.json', '.js'); fs.writeFileSync( jsFilePath, `const ${fileIdentifier.replace(/\W/g, '_')} = ${JSON.stringify(istanbulCoverage, null, 2)};`, 'utf-8', ); console.log(`Coverage JS file saved at: ${jsFilePath}`); } catch (error) { console.error(`Error processing ${fileIdentifier} coverage:`, error); } };
for (const entry of coverage) {
const fileName = entry.url.split('/').pop();
if (fileName) {
await processCoverageFile(entry, fileName);
}
}
console.log('Test coverage processing completed.');
}
2. Jenkins QA Configuration
npm_e2etest: {
script {
echo "Starting npm_e2etest..."
try {
npm().run("swb:e2e")
if (fileExists("coverage/summary")) { echo "Directory 'coverage/summary' exists after the tests." } else { echo "Directory 'coverage/summary' does NOT exist after the tests." } } catch (Exception e) { echo "Error occurred during e2e tests: ${e}" currentBuild.result = 'FAILURE' throw e } finally { echo "Publishing Junit Test Results report..." try { npm().run("nyc-report") npm().run("nyc-report-format-generator") echo "Running JUnit Report..." echo "Archiving screenshots..." archiveArtifacts artifacts: '**/test-results/**/*.png', allowEmptyArchive: true echo "Archiving Playwright HTML Report..." echo "Archiving NYC coverage reports..." archiveArtifacts artifacts: 'coverage/summary/**/*', allowEmptyArchive: true if (fileExists("./coverage/summary/coverage.txt")) { echo "Reading E2E Tests Coverage Report..." def e2eRawReport = readFile("./coverage/summary/coverage.txt") def e2eCoverageReport = e2eRawReport.split('\n').take(4).join('\n') addCommentsInPullRequest("### E2E Tests Coverage Report\n ") } else { echo "Coverage report file not found: ./coverage/summary/coverage.txt" } } } } } **Tools/Framework Used** Playwright for Component Tests V8-to-Istanbul converter for coverage NYC report generator Jenkins for CI 📌 Support Needed I need assistance to identify why the coverage summary and processed coverage reports are not generated on Jenkins, even though the same configuration works locally. Any guidance or recommendations to align the Jenkins execution with the local coverage process would be helpful.


Top comments (0)