UNPKG

2.22 kBJavaScriptView Raw
1"use strict";
2var html_reporter_1 = require("./reporters/html-reporter");
3exports.EReportType = {
4 NOTE: 'NOTE',
5 WARNING: 'WARNING',
6 ERROR: 'ERROR',
7};
8exports.EExecutionStep = {
9 INIT: 'INIT',
10 SCENARIO: 'SCENARIO',
11 SETUP: 'SETUP',
12 TEARDOWN: 'TEARDOWN',
13};
14var Reports = (function () {
15 function Reports() {
16 this._step = exports.EExecutionStep.INIT;
17 this._reports = new Map();
18 this._reports.set(exports.EExecutionStep.INIT, []);
19 this._reports.set(exports.EExecutionStep.SCENARIO, []);
20 this._reports.set(exports.EExecutionStep.SETUP, []);
21 this._reports.set(exports.EExecutionStep.TEARDOWN, []);
22 this._reporters = new Map();
23 this._reporters.set('html', new html_reporter_1.HtmlReporter());
24 }
25 Reports.prototype._setStep = function (executionStep) {
26 this._step = executionStep;
27 };
28 Reports.prototype._setTest = function (testData) {
29 this._currentTestData = testData;
30 };
31 Reports.prototype._setInstanceNumber = function (instance) {
32 this._instance = instance;
33 };
34 Reports.prototype.warning = function (params) {
35 params.type = exports.EReportType.WARNING;
36 this._report(params);
37 };
38 Reports.prototype.note = function (params) {
39 params.type = exports.EReportType.NOTE;
40 this._report(params);
41 };
42 Reports.prototype.error = function (params) {
43 params.type = exports.EReportType.ERROR;
44 this._report(params);
45 };
46 Reports.prototype._report = function (params) {
47 params.timestamp = new Date();
48 params.instance = this._instance;
49 this._reports.get(this._step).push(params);
50 };
51 Reports.prototype.saveReport = function (reports, testName, reporters, path) {
52 var _this = this;
53 if (reporters.length === 0 || !path) {
54 return;
55 }
56 reporters.forEach(function (reporterName) {
57 var reporter = _this._reporters.get(reporterName);
58 if (reporter) {
59 reporter.writeTestReport(testName, reports, path);
60 }
61 });
62 };
63 return Reports;
64}());
65exports.Reports = Reports;
66//# sourceMappingURL=reports.js.map
\No newline at end of file