I ma trying to generate some coverage for my tests in Protractor. I am using Istanbul Istanbul and also I am following this tutorial: coverage My code inside [protr.conf.js is this:
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)
Sorry I am just a beginner.
Aucun commentaire:
Enregistrer un commentaire