aft-jest-reporter
Version:
Automated Functional Testing (AFT) Reporter for use with Jest Test Framework
48 lines • 2.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const aft_jest_test_1 = require("./aft-jest-test");
const aft_core_1 = require("aft-core");
class AftJestReporter {
constructor(globalConfig, reporterOptions, reporterContext) {
this._globalConfig = globalConfig;
this._options = reporterOptions;
this._context = reporterContext;
}
// start: required Reporter functions
onRunStart(results, options) {
// clear all previously cached test results
aft_core_1.FileSystemMap.removeMapFile(aft_jest_test_1.AftJestTest.name);
/**
* NOTE Jest does not provide the ability to programmatically skip a test
* nor would the Reporter be allowed to perform this action so we
* must use the `AftJestTest.shouldRun` in the beginning of a `test` function
*/
}
onRunComplete(testContexts, results) {
/* do nothing */
}
getLastError() {
/* do nothing */
}
// end: required Reporter functions
// start: optional Reporter functions
onTestCaseResult(test, testCaseResult) {
const t = new aft_jest_test_1.AftJestTest(testCaseResult, null, { _preventCacheClear: true });
if (t.results.length === 0) {
// aftJestTest was NOT used in test
switch (testCaseResult.status) {
case "skipped":
return aft_core_1.Err.handleAsync(() => { var _a; return t.skipped((_a = testCaseResult.failureMessages) === null || _a === void 0 ? void 0 : _a.join('\n')); }, { errLevel: 'none' })
.then();
case "failed":
return aft_core_1.Err.handleAsync(() => { var _a; return t.fail((_a = testCaseResult.failureMessages) === null || _a === void 0 ? void 0 : _a.join('\n')); }, { errLevel: 'none' })
.then();
case "passed":
return aft_core_1.Err.handleAsync(() => t.pass(), { errLevel: 'none' })
.then();
}
}
}
}
exports.default = AftJestReporter;
//# sourceMappingURL=aft-jest-reporter.js.map