Add ability to run tests with coverage report
This commit is contained in:
parent
e17e195479
commit
491f69df80
5 changed files with 36 additions and 27 deletions
|
@ -22,7 +22,7 @@ glob.sync('**/*.js', {cwd: libPath}).forEach(function (relativePath) {
|
|||
fs.writeFileSync(generatedPath, generated)
|
||||
})
|
||||
|
||||
var asarPath = path.join(outputPath, 'electron-instrumented.asar')
|
||||
var asarPath = path.join(outputPath, 'electron.asar')
|
||||
asar.createPackageWithOptions(path.join(outputPath, 'lib'), asarPath, {}, function (error) {
|
||||
if (error) {
|
||||
console.error(error.stack || error)
|
||||
|
|
|
@ -33,7 +33,7 @@ const addUnrequiredFiles = (coverage) => {
|
|||
}
|
||||
|
||||
// Generate a code coverage report in out/coverage/lcov-report
|
||||
exports.generate = () => {
|
||||
exports.generateReport = () => {
|
||||
const coverage = window.__coverage__
|
||||
if (coverage == null) return
|
||||
|
||||
|
@ -49,27 +49,3 @@ exports.generate = () => {
|
|||
reporter.addAll(['text', 'lcov'])
|
||||
reporter.write(collector, true, function () {})
|
||||
}
|
||||
|
||||
// Generate an instrumented .asar file for all the files in lib/ and save it
|
||||
// to out/coverage/electron-instrumented.asar
|
||||
exports.instrument = () => {
|
||||
const instrumenter = new Instrumenter()
|
||||
|
||||
glob.sync('**/*.js', {cwd: libPath}).forEach(function (relativePath) {
|
||||
const rawPath = path.join(libPath, relativePath)
|
||||
const raw = fs.readFileSync(rawPath, 'utf8')
|
||||
|
||||
const generatedPath = path.join(outputPath, 'lib', relativePath)
|
||||
const generated = instrumenter.instrumentSync(raw, rawPath)
|
||||
mkdirp.sync(path.dirname(generatedPath))
|
||||
fs.writeFileSync(generatedPath, generated)
|
||||
})
|
||||
|
||||
const asarPath = path.join(outputPath, 'electron-instrumented.asar')
|
||||
asar.createPackageWithOptions(path.join(outputPath, 'lib'), asarPath, {}, function (error) {
|
||||
if (error) {
|
||||
console.error(error.stack || error)
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
}
|
|
@ -83,7 +83,7 @@
|
|||
Mocha.utils.highlightTags('code');
|
||||
if (isCi)
|
||||
ipcRenderer.send('process.exit', runner.failures);
|
||||
require('./coverage').generate()
|
||||
require('../coverage/reporter').generateReport()
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue