-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3375 from kiva/VUE-793
fix(cypress): remove old reports before cypress tests start VUE-793
- Loading branch information
Showing
1 changed file
with
36 additions
and
16 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
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); | ||
}); | ||
}); | ||
}; |