我正在尝试为我在量角器中的测试生成一些覆盖率。我正在使用Istanbul Istanbul,并且正在关注本教程: coverage 我在[protr.conf.js]中的代码是这样的:
var istanbul = require('istanbul');
var collector = new istanbul.Collector();
var reporter;
var waitPlugin = require('./src/test/javascript/waitPlugin.js');
function report() {
if (reporter) {
reporter.add('html');
reporter.write(collector, true, function () {
console.log('Coverage report successfully written');
});
}
}
exports.config = {
baseUrl: 'http://localhost:8080/#/',
// use npm run e2e
specs: [
'./e2e/*.e2e.js'
],
exclude: [],
framework: 'jasmine2',
//path: 'node_modules/protractor-istanbul-plugin'
plugins: [{
path: './src/test/javascript/waitPlugin.js'
}
],
allScriptsTimeout: 110000,
directConnect: true,
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': ['show-fps-counter=true']
}
},
onPrepare: function() {
browser.ignoreSynchronization = false;
var jasmineEnv = jasmine.getEnv();
waitPlugin.setOnComplete(report);
browser.driver.manage().window().maximize();
// browser.get('${testPortalAddress}');
jasmineEnv.addReporter(new function () {
this.specDone = function (spec) {
if (spec.status !== 'failed') {
var name = spec.fullName.replace(/ /g, '_');
var reportfile = 'coverage/integration/json/' + name;
reporter = new istanbul.Reporter(undefined, reportfile);
var promise = browser.driver.executeScript('return __coverage__;')
.then(function (coverageResults) {
collector.add(coverageResults);
});
waitPlugin.waitList.push(promise);
}
};
});
},
useAllAngular2AppRoots: false
};
Fail: ./src/test/javascript/waitPlugin.js Plugin Tests
[22:39:32] E/plugins - Failure during teardown: unknown error: __coverage__ is not defined
(Session info: chrome=70.0.3538.102)
对不起,我只是一个初学者。