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
53 lines (42 loc) · 1.72 KB
/
Copy pathindex.js
File metadata and controls
53 lines (42 loc) · 1.72 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
51
52
53
"use strict";
var _ = require("lodash");
var formatter = require("./formatter");
var writer = require("./writer");
var CucumberReporter = function (baseReporterDecorator, config, logger, helper) {
var log = logger.create("reporter.cucumber");
var reporterConfig = config.cucumberReporter || {};
var out = reporterConfig.out || "stdout";
var history = {};
baseReporterDecorator(this);
this.adapters = [function (msg) {
process.stdout.write.bind(process.stdout)(msg);
}];
this.onSpecComplete = function (browser, result) {
console.log("--------------------------------- debug ---------------------------------");
console.log(JSON.stringify(result));
var suite = result.suite[1];
var scenario = result.suite[2];
var 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);
}
}
console.log("--------------------------------- debug ---------------------------------");
};
this.onRunComplete = function () {
var cucumberJson = formatter(history);
var 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]
};