Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { browser } from 'protractor';
import fs = require('fs');
declare var module: NodeModule;
var myReporter = {
specDone: function (result) {
if (result.failedExpectations.length > 0) {
browser.getProcessedConfig().then(function (config) {
browser.takeScreenshot().then(function (png) {
var dirPath = './reports/screenshots/';
if (!fs.existsSync('./reports')) {
fs.mkdirSync('./reports');
if (!fs.existsSync(dirPath))
fs.mkdirSync(dirPath);
}
var fileName = (config.capabilities.browserName + '-' + result.fullName).replace(/[\/\\]/g, ' ').substring(0, 230);
var stream = fs.createWriteStream(dirPath + fileName + '.png');
stream.write(new Buffer(png, 'base64'));
stream.end();
}, function (error) {
console.log("failed to take screenshot");
})
})
}
}
}
module.exports = myReporter;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.