Skip to content

Commit

Permalink
Merge pull request #3375 from kiva/VUE-793
Browse files Browse the repository at this point in the history
fix(cypress): remove old reports before cypress tests start VUE-793
  • Loading branch information
emuvente authored Oct 27, 2021
2 parents 637de23 + 0695b35 commit 082cdb6
Showing 1 changed file with 36 additions and 16 deletions.
52 changes: 36 additions & 16 deletions test/e2e/plugins/merge-reports.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,48 @@
const path = require('path');
const { mergeFiles } = require('junit-report-merger');
const rimraf = require('rimraf');

/* eslint-disable no-console */
module.exports = on => {
// Merge together junit reports from all spec files into single junit report
on('after:run', results => {
if (results) {
console.log('Merging test result reports...');
const reportFileGlob = `${__dirname}/../results/*.xml`;
const combinedReportPath = path.join(__dirname, '..', 'results', 'combined.xml');

const outputFile = path.join(__dirname, '..', 'results', 'combined.xml');
const inputFiles = [`${__dirname}/../results/*.xml`];
const options = {
onFileMatched: ({ filePath }) => {
console.log(`Merging: ${filePath}`);
}
};
// Delete any existing reports before the run starts
on('before:run', () => {
console.log('Deleting old test result reports...');

mergeFiles(outputFile, inputFiles, options).then(() => {
console.log(`Merged report generated at ${outputFile}`);
}).catch(e => {
console.error(e);
return new Promise((resolve, reject) => {
rimraf(reportFileGlob, err => {
if (err) {
console.error('Error while deleting old test result reports:', err);
reject(err);
} else {
console.log('Deleted old test result reports');
resolve();
}
});
} else {
});
});

// Merge together junit reports from all spec files into single junit report
on('after:run', results => {
if (!results) {
console.log('Skipping report merging (no test results)');
return Promise.resolve();
}

console.log('Merging test result reports...');

const options = {
onFileMatched: ({ filePath }) => {
console.log(`Merging: ${filePath}`);
}
};

return mergeFiles(combinedReportPath, [reportFileGlob], options).then(() => {
console.log(`Merged report generated at ${combinedReportPath}`);
}).catch(e => {
console.error(e);
});
});
};

0 comments on commit 082cdb6

Please sign in to comment.