aye-spy
Version:
A visual regression tool
61 lines (48 loc) • 1.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _logger = require('./logger');
var _logger2 = _interopRequireDefault(_logger);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class Reporter {
constructor() {
this._state = {
passed: {
count: 0,
scenarios: []
},
failed: {
count: 0,
scenarios: []
}
};
}
get state() {
return this._state;
}
pass(scenarioName) {
if (!scenarioName) throw 'No scenario name reported';
this.state.passed.scenarios.push(scenarioName);
this.state.passed.count++;
}
fail(scenarioName) {
if (!scenarioName) throw 'No scenario name reported';
this.state.failed.scenarios.push(scenarioName);
this.state.failed.count++;
}
generateReport() {
_logger2.default.info('Reporter', `
AyeSpy
---------------------
Scenarios Passed: ${this.state.passed.count}
Scenarios Failed: ${this.state.failed.count}
---------------------
`);
if (this.state.failed.count > 0) {
_logger2.default.info('Reporter', 'Failed Scenarios:');
this.state.failed.scenarios.forEach(scenario => _logger2.default.info('Reporter', scenario));
}
}
}
exports.default = Reporter;