pulsar/spec/jasmine-list-reporter.js

36 lines
916 B
JavaScript
Raw Normal View History

2019-05-31 19:33:56 +03:00
const { TerminalReporter } = require('jasmine-tagged');
class JasmineListReporter extends TerminalReporter {
2019-05-31 19:33:56 +03:00
fullDescription(spec) {
let fullDescription = 'it ' + spec.description;
let currentSuite = spec.suite;
while (currentSuite) {
2019-05-31 19:33:56 +03:00
fullDescription = currentSuite.description + ' > ' + fullDescription;
currentSuite = currentSuite.parentSuite;
}
2019-05-31 19:33:56 +03:00
return fullDescription;
}
2019-05-31 19:33:56 +03:00
reportSpecStarting(spec) {
this.print_(this.fullDescription(spec) + ' ');
}
2019-05-31 19:33:56 +03:00
reportSpecResults(spec) {
const result = spec.results();
if (result.skipped) {
2019-05-31 19:33:56 +03:00
return;
2019-02-05 18:40:52 +03:00
}
2019-05-31 19:33:56 +03:00
let msg = '';
2019-02-05 18:40:52 +03:00
if (result.passed()) {
2019-05-31 19:33:56 +03:00
msg = this.stringWithColor_('[pass]', this.color_.pass());
} else {
2019-05-31 19:33:56 +03:00
msg = this.stringWithColor_('[FAIL]', this.color_.fail());
this.addFailureToFailures_(spec);
}
2019-05-31 19:33:56 +03:00
this.printLine_(msg);
}
}
2019-05-31 19:33:56 +03:00
module.exports = { JasmineListReporter };