forked from SAP-archive/karma-ui5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
50 lines (39 loc) · 1.35 KB
/
Copy pathindex.js
File metadata and controls
50 lines (39 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"use strict";
const _ = require("lodash");
const formatter = require("./formatter");
const writer = require("./writer");
const CucumberReporter = function(baseReporterDecorator, config, logger, helper) {
const log = logger.create("reporter.cucumber");
const reporterConfig = config.cucumberReporter || {};
const out = reporterConfig.out || "stdout";
const history = {};
baseReporterDecorator(this);
this.adapters = [function(msg) {
process.stdout.write.bind(process.stdout)(msg);
}];
this.onSpecComplete = function(browser, result) {
const suite = result.suite[1];
const scenario = result.description;
const step = result.suite[3];
if (!reporterConfig.prefix || reporterConfig.prefix && _.startsWith(suite, reporterConfig.prefix)) {
history[suite] = history[suite] || {};
history[suite][scenario] = history[suite][scenario] || [];
if (step) {
history[suite][scenario].push(result);
}
}
};
this.onRunComplete = function() {
const cucumberJson = formatter(history);
const jsonResult = JSON.stringify(cucumberJson, null, 2) + "\n";
if (out === "stdout") {
process.stdout.write(jsonResult);
} else {
writer(helper, out, log, jsonResult);
}
};
};
CucumberReporter.$inject = ["baseReporterDecorator", "config", "logger", "helper", "formatError"];
module.exports = {
"reporter:cucumber": ["type", CucumberReporter]
};