One way to see protractor test run results, is to use an existing package, called jasmine2-html-reporter that will help you see a reporter in html format for Jasmine and Protractor. The big advantage of this is that it's able to generate a screenshot every time a test test fails.
In order to use it you need to npm install it and to add it in your protractor config.js file, in onprepare function
$ npm install protractor-jasmine2-html-reporter
There are other options that you can use, like FixedScreenshotName, CleanDestination, showPassed, etc.
The test results will show
- 'passed' for every 'expect' inside a spec ('it' statement)
- if there is no 'expect' inside 'it', it will be marked with 'skipped'
- if an error occurs, it will show an error + a screenshot
In order to use it you need to npm install it and to add it in your protractor config.js file, in onprepare function
$ npm install protractor-jasmine2-html-reporter
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
exports.config = {
// ...
onPrepare: function() {
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: './protractor/reports/logs/htmlReports',
takeScreenshots: true,
takeScreenshotsOnlyOnFailures: true
})
);
}
}
There are other options that you can use, like FixedScreenshotName, CleanDestination, showPassed, etc.
The test results will show
- 'passed' for every 'expect' inside a spec ('it' statement)
- if there is no 'expect' inside 'it', it will be marked with 'skipped'
- if an error occurs, it will show an error + a screenshot
Later, you can use test results files in a CI system, like Jenkins and attach the screenshots for failed tests as artifacts.
Happy testing and... make it green, becomes a dream :).
No comments:
Post a Comment