@wdio/reporter 8.15.0 → 8.15.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.COLORS = void 0;
4
+ exports.COLORS = {
5
+ pass: 90,
6
+ fail: 31,
7
+ 'bright pass': 92,
8
+ 'bright fail': 91,
9
+ 'bright yellow': 93,
10
+ pending: 36,
11
+ suite: 0,
12
+ 'error title': 0,
13
+ 'error message': 31,
14
+ 'error stack': 90,
15
+ checkmark: 32,
16
+ fast: 90,
17
+ medium: 33,
18
+ slow: 31,
19
+ green: 32,
20
+ light: 90,
21
+ 'diff gutter': 90,
22
+ 'diff added': 32,
23
+ 'diff removed': 31,
24
+ 'diff added inline': '30;42',
25
+ 'diff removed inline': '30;41'
26
+ };
package/cjs/index.js ADDED
@@ -0,0 +1,265 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RunnerStats = exports.TestStats = exports.HookStats = exports.SuiteStats = void 0;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_events_1 = require("node:events");
9
+ const logger_1 = __importDefault(require("@wdio/logger"));
10
+ const utils_js_1 = require("./utils.js");
11
+ const suite_js_1 = __importDefault(require("./stats/suite.js"));
12
+ exports.SuiteStats = suite_js_1.default;
13
+ const hook_js_1 = __importDefault(require("./stats/hook.js"));
14
+ exports.HookStats = hook_js_1.default;
15
+ const test_js_1 = __importDefault(require("./stats/test.js"));
16
+ exports.TestStats = test_js_1.default;
17
+ const runner_js_1 = __importDefault(require("./stats/runner.js"));
18
+ exports.RunnerStats = runner_js_1.default;
19
+ const log = (0, logger_1.default)('WDIOReporter');
20
+ class WDIOReporter extends node_events_1.EventEmitter {
21
+ options;
22
+ outputStream;
23
+ failures = 0;
24
+ suites = {};
25
+ hooks = {};
26
+ tests = {};
27
+ currentSuites = [];
28
+ counts = {
29
+ suites: 0,
30
+ tests: 0,
31
+ hooks: 0,
32
+ passes: 0,
33
+ skipping: 0,
34
+ failures: 0
35
+ };
36
+ retries = 0;
37
+ runnerStat;
38
+ isContentPresent = false;
39
+ specs = [];
40
+ currentSpec;
41
+ constructor(options) {
42
+ super();
43
+ this.options = options;
44
+ // ensure the report directory exists
45
+ if (this.options.outputDir) {
46
+ try {
47
+ node_fs_1.default.mkdirSync(this.options.outputDir, { recursive: true });
48
+ }
49
+ catch (err) {
50
+ log.error(`Couldn't create output dir: ${err.stack}`);
51
+ }
52
+ }
53
+ this.outputStream = (this.options.stdout || !this.options.logFile) && this.options.writeStream
54
+ ? this.options.writeStream
55
+ : node_fs_1.default.createWriteStream(this.options.logFile);
56
+ let currentTest;
57
+ const rootSuite = new suite_js_1.default({
58
+ title: '(root)',
59
+ fullTitle: '(root)',
60
+ file: ''
61
+ });
62
+ this.currentSuites.push(rootSuite);
63
+ this.on('client:beforeCommand', this.onBeforeCommand.bind(this));
64
+ this.on('client:afterCommand', this.onAfterCommand.bind(this));
65
+ this.on('runner:start', /* istanbul ignore next */ (runner) => {
66
+ rootSuite.cid = runner.cid;
67
+ this.specs.push(...runner.specs);
68
+ this.runnerStat = new runner_js_1.default(runner);
69
+ this.onRunnerStart(this.runnerStat);
70
+ });
71
+ this.on('suite:start', /* istanbul ignore next */ (params) => {
72
+ /**
73
+ * the jasmine framework doesn't give us information about the file
74
+ * therefore we need to propagate these information into params
75
+ */
76
+ if (!params.file) {
77
+ params.file = !params.parent
78
+ ? this.specs.shift() || 'unknown spec file'
79
+ : this.currentSpec;
80
+ this.currentSpec = params.file;
81
+ }
82
+ const suite = new suite_js_1.default(params);
83
+ const currentSuite = this.currentSuites[this.currentSuites.length - 1];
84
+ currentSuite.suites.push(suite);
85
+ this.currentSuites.push(suite);
86
+ this.suites[suite.uid] = suite;
87
+ this.onSuiteStart(suite);
88
+ });
89
+ this.on('hook:start', /* istanbul ignore next */ (hook) => {
90
+ const hookStats = new hook_js_1.default(hook);
91
+ const currentSuite = this.currentSuites[this.currentSuites.length - 1];
92
+ currentSuite.hooks.push(hookStats);
93
+ currentSuite.hooksAndTests.push(hookStats);
94
+ this.hooks[hook.uid] = hookStats;
95
+ this.onHookStart(hookStats);
96
+ });
97
+ this.on('hook:end', /* istanbul ignore next */ (hook) => {
98
+ const hookStats = this.hooks[hook.uid];
99
+ hookStats.complete((0, utils_js_1.getErrorsFromEvent)(hook));
100
+ this.counts.hooks++;
101
+ this.onHookEnd(hookStats);
102
+ });
103
+ this.on('test:start', /* istanbul ignore next */ (test) => {
104
+ test.retries = this.retries;
105
+ currentTest = new test_js_1.default(test);
106
+ const currentSuite = this.currentSuites[this.currentSuites.length - 1];
107
+ currentSuite.tests.push(currentTest);
108
+ currentSuite.hooksAndTests.push(currentTest);
109
+ this.tests[test.uid] = currentTest;
110
+ this.onTestStart(currentTest);
111
+ });
112
+ this.on('test:pass', /* istanbul ignore next */ (test) => {
113
+ const testStat = this.tests[test.uid];
114
+ testStat.pass();
115
+ this.counts.passes++;
116
+ this.counts.tests++;
117
+ this.onTestPass(testStat);
118
+ });
119
+ this.on('test:skip', (test) => {
120
+ const testStat = this.tests[test.uid];
121
+ currentTest.skip(test.pendingReason);
122
+ this.counts.skipping++;
123
+ this.counts.tests++;
124
+ this.onTestSkip(testStat);
125
+ });
126
+ this.on('test:fail', /* istanbul ignore next */ (test) => {
127
+ const testStat = this.tests[test.uid];
128
+ testStat.fail((0, utils_js_1.getErrorsFromEvent)(test));
129
+ this.counts.failures++;
130
+ this.counts.tests++;
131
+ this.onTestFail(testStat);
132
+ });
133
+ this.on('test:retry', (test) => {
134
+ const testStat = this.tests[test.uid];
135
+ testStat.fail((0, utils_js_1.getErrorsFromEvent)(test));
136
+ this.onTestRetry(testStat);
137
+ this.retries++;
138
+ });
139
+ this.on('test:pending', (test) => {
140
+ test.retries = this.retries;
141
+ const currentSuite = this.currentSuites[this.currentSuites.length - 1];
142
+ currentTest = new test_js_1.default(test);
143
+ /**
144
+ * In Mocha: tests that are skipped don't have a start event but a test end.
145
+ * In Jasmine: tests have a start event, therefore we need to replace the
146
+ * test instance with the pending test here
147
+ */
148
+ if (test.uid in this.tests && this.tests[test.uid].state !== 'pending') {
149
+ currentTest.uid = test.uid in this.tests ? 'skipped-' + this.counts.skipping : currentTest.uid;
150
+ }
151
+ const suiteTests = currentSuite.tests;
152
+ if (!suiteTests.length || currentTest.uid !== suiteTests[suiteTests.length - 1].uid) {
153
+ currentSuite.tests.push(currentTest);
154
+ currentSuite.hooksAndTests.push(currentTest);
155
+ }
156
+ else {
157
+ suiteTests[suiteTests.length - 1] = currentTest;
158
+ currentSuite.hooksAndTests[currentSuite.hooksAndTests.length - 1] = currentTest;
159
+ }
160
+ this.tests[currentTest.uid] = currentTest;
161
+ currentTest.skip(test.pendingReason);
162
+ this.counts.skipping++;
163
+ this.counts.tests++;
164
+ this.onTestSkip(currentTest);
165
+ });
166
+ this.on('test:end', /* istanbul ignore next */ (test) => {
167
+ const testStat = this.tests[test.uid];
168
+ this.retries = 0;
169
+ this.onTestEnd(testStat);
170
+ });
171
+ this.on('suite:end', /* istanbul ignore next */ (suite) => {
172
+ const suiteStat = this.suites[suite.uid];
173
+ suiteStat.complete();
174
+ this.currentSuites.pop();
175
+ this.onSuiteEnd(suiteStat);
176
+ });
177
+ this.on('runner:end', /* istanbul ignore next */ (runner) => {
178
+ rootSuite.complete();
179
+ if (this.runnerStat) {
180
+ this.runnerStat.failures = runner.failures;
181
+ this.runnerStat.retries = runner.retries;
182
+ this.runnerStat.complete();
183
+ this.onRunnerEnd(this.runnerStat);
184
+ }
185
+ const logFile = this.options.logFile;
186
+ if (!this.isContentPresent && logFile && node_fs_1.default.existsSync(logFile)) {
187
+ node_fs_1.default.unlinkSync(logFile);
188
+ }
189
+ });
190
+ /**
191
+ * browser client event handlers
192
+ */
193
+ this.on('client:beforeCommand', /* istanbul ignore next */ (payload) => {
194
+ if (!currentTest) {
195
+ return;
196
+ }
197
+ currentTest.output.push(Object.assign(payload, { type: 'command' }));
198
+ });
199
+ this.on('client:afterCommand', /* istanbul ignore next */ (payload) => {
200
+ if (!currentTest) {
201
+ return;
202
+ }
203
+ currentTest.output.push(Object.assign(payload, { type: 'result' }));
204
+ });
205
+ }
206
+ /**
207
+ * allows reporter to stale process shutdown process until required sync work
208
+ * is done (e.g. when having to send data to some server or any other async work)
209
+ */
210
+ get isSynchronised() {
211
+ return true;
212
+ }
213
+ /**
214
+ * function to write to reporters output stream
215
+ */
216
+ write(content) {
217
+ if (content) {
218
+ this.isContentPresent = true;
219
+ }
220
+ this.outputStream.write(content);
221
+ }
222
+ /* istanbul ignore next */
223
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
224
+ onRunnerStart(runnerStats) { }
225
+ /* istanbul ignore next */
226
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
227
+ onBeforeCommand(commandArgs) { }
228
+ /* istanbul ignore next */
229
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
230
+ onAfterCommand(commandArgs) { }
231
+ /* istanbul ignore next */
232
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
233
+ onSuiteStart(suiteStats) { }
234
+ /* istanbul ignore next */
235
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
236
+ onHookStart(hookStat) { }
237
+ /* istanbul ignore next */
238
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
239
+ onHookEnd(hookStats) { }
240
+ /* istanbul ignore next */
241
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
242
+ onTestStart(testStats) { }
243
+ /* istanbul ignore next */
244
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
245
+ onTestPass(testStats) { }
246
+ /* istanbul ignore next */
247
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
248
+ onTestFail(testStats) { }
249
+ /* istanbul ignore next */
250
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
251
+ onTestRetry(testStats) { }
252
+ /* istanbul ignore next */
253
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
254
+ onTestSkip(testStats) { }
255
+ /* istanbul ignore next */
256
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
257
+ onTestEnd(testStats) { }
258
+ /* istanbul ignore next */
259
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
260
+ onSuiteEnd(suiteStats) { }
261
+ /* istanbul ignore next */
262
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
263
+ onRunnerEnd(runnerStats) { }
264
+ }
265
+ exports.default = WDIOReporter;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const runnable_js_1 = __importDefault(require("./runnable.js"));
7
+ class HookStats extends runnable_js_1.default {
8
+ uid;
9
+ cid;
10
+ title;
11
+ parent;
12
+ // Mocha only
13
+ body;
14
+ errors;
15
+ error;
16
+ state;
17
+ currentTest;
18
+ constructor(runner) {
19
+ super('hook');
20
+ this.uid = runnable_js_1.default.getIdentifier(runner);
21
+ this.cid = runner.cid;
22
+ this.title = runner.title;
23
+ this.parent = runner.parent;
24
+ this.currentTest = runner.currentTest;
25
+ this.body = runner.body;
26
+ }
27
+ complete(errors) {
28
+ this.errors = errors;
29
+ if (errors && errors.length) {
30
+ this.error = errors[0];
31
+ this.state = 'failed';
32
+ }
33
+ super.complete();
34
+ }
35
+ }
36
+ exports.default = HookStats;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Main class for a runnable class (e.g. test, suite or a hook)
5
+ * mainly used to capture its running duration
6
+ */
7
+ class RunnableStats {
8
+ type;
9
+ start = new Date();
10
+ end;
11
+ _duration = 0;
12
+ constructor(type) {
13
+ this.type = type;
14
+ }
15
+ complete() {
16
+ this.end = new Date();
17
+ this._duration = this.end.getTime() - this.start.getTime();
18
+ }
19
+ get duration() {
20
+ if (this.end) {
21
+ return this._duration;
22
+ }
23
+ return new Date().getTime() - this.start.getTime();
24
+ }
25
+ /**
26
+ * ToDo: we should always rely on uid
27
+ */
28
+ static getIdentifier(runner) {
29
+ return runner.uid || runner.title;
30
+ }
31
+ }
32
+ exports.default = RunnableStats;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const runnable_js_1 = __importDefault(require("./runnable.js"));
7
+ const utils_js_1 = require("../utils.js");
8
+ /**
9
+ * Class to capture statistics about a test run. A test run is a single instance that
10
+ * runs one or more spec files
11
+ */
12
+ class RunnerStats extends runnable_js_1.default {
13
+ cid;
14
+ capabilities;
15
+ sanitizedCapabilities;
16
+ config;
17
+ specs;
18
+ sessionId;
19
+ isMultiremote;
20
+ instanceOptions;
21
+ retry;
22
+ failures;
23
+ retries;
24
+ constructor(runner) {
25
+ super('runner');
26
+ this.cid = runner.cid;
27
+ this.capabilities = runner.capabilities;
28
+ this.sanitizedCapabilities = (0, utils_js_1.sanitizeCaps)(runner.capabilities);
29
+ this.config = runner.config;
30
+ this.specs = runner.specs;
31
+ this.sessionId = runner.sessionId;
32
+ this.isMultiremote = runner.isMultiremote;
33
+ this.instanceOptions = runner.instanceOptions;
34
+ this.retry = runner.retry;
35
+ }
36
+ }
37
+ exports.default = RunnerStats;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const runnable_js_1 = __importDefault(require("./runnable.js"));
7
+ /**
8
+ * Class describing statistics about a single suite.
9
+ */
10
+ class SuiteStats extends runnable_js_1.default {
11
+ uid;
12
+ cid;
13
+ file;
14
+ title;
15
+ fullTitle;
16
+ tags;
17
+ tests = [];
18
+ hooks = [];
19
+ suites = [];
20
+ parent;
21
+ /**
22
+ * an array of hooks and tests stored in order as they happen
23
+ */
24
+ hooksAndTests = [];
25
+ description;
26
+ rule;
27
+ constructor(suite) {
28
+ super(suite.type || 'suite');
29
+ this.uid = runnable_js_1.default.getIdentifier(suite);
30
+ this.cid = suite.cid;
31
+ this.file = suite.file;
32
+ this.title = suite.title;
33
+ this.fullTitle = suite.fullTitle;
34
+ this.tags = suite.tags;
35
+ this.parent = suite.parent;
36
+ /**
37
+ * only Cucumber
38
+ */
39
+ this.description = suite.description;
40
+ this.rule = suite.rule;
41
+ }
42
+ }
43
+ exports.default = SuiteStats;
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_util_1 = require("node:util");
7
+ const diff_1 = require("diff");
8
+ const object_inspect_1 = __importDefault(require("object-inspect"));
9
+ const runnable_js_1 = __importDefault(require("./runnable.js"));
10
+ const utils_js_1 = require("../utils.js");
11
+ const maxStringLength = 2048;
12
+ /**
13
+ * TestStats class
14
+ * captures data on a test.
15
+ */
16
+ class TestStats extends runnable_js_1.default {
17
+ uid;
18
+ cid;
19
+ title;
20
+ currentTest;
21
+ fullTitle;
22
+ output;
23
+ argument;
24
+ retries;
25
+ parent;
26
+ /**
27
+ * initial test state is pending
28
+ * the state can change to the following: passed, skipped, failed
29
+ */
30
+ state;
31
+ pendingReason;
32
+ errors;
33
+ error;
34
+ body;
35
+ constructor(test) {
36
+ super('test');
37
+ this.uid = runnable_js_1.default.getIdentifier(test);
38
+ this.cid = test.cid;
39
+ this.title = test.title;
40
+ this.fullTitle = test.fullTitle;
41
+ this.output = [];
42
+ this.argument = test.argument;
43
+ this.retries = test.retries;
44
+ this.parent = test.parent;
45
+ // Mocha only
46
+ this.body = test.body;
47
+ /**
48
+ * initial test state is pending
49
+ * the state can change to the following: passed, skipped, failed
50
+ */
51
+ this.state = 'pending';
52
+ }
53
+ pass() {
54
+ this.complete();
55
+ this.state = 'passed';
56
+ }
57
+ skip(reason) {
58
+ this.pendingReason = reason;
59
+ this.state = 'skipped';
60
+ }
61
+ fail(errors) {
62
+ this.complete();
63
+ this.state = 'failed';
64
+ /**
65
+ * Iterates through all errors to check if they're a type of 'AssertionError',
66
+ * and formats it if so. Otherwise, just leaves error as is
67
+ */
68
+ const formattedErrors = errors?.map((err) => (
69
+ /**
70
+ * only format if error object has either an "expected" or "actual" property set
71
+ */
72
+ ((err.expected || err.actual) && !node_util_1.types.isProxy(err.actual)) &&
73
+ /**
74
+ * and if they aren't already formated, e.g. in Jasmine
75
+ */
76
+ (err.message && !err.message.includes('Expected: ') && !err.message.includes('Received: '))
77
+ ? this._stringifyDiffObjs(err)
78
+ : err));
79
+ this.errors = formattedErrors;
80
+ if (formattedErrors && formattedErrors.length) {
81
+ this.error = formattedErrors[0];
82
+ }
83
+ }
84
+ _stringifyDiffObjs(err) {
85
+ const inspectOpts = { maxStringLength };
86
+ const expected = (0, object_inspect_1.default)(err.expected, inspectOpts);
87
+ const actual = (0, object_inspect_1.default)(err.actual, inspectOpts);
88
+ let msg = (0, diff_1.diffWordsWithSpace)(actual, expected)
89
+ .map((str) => (str.added
90
+ ? (0, utils_js_1.colorLines)('diff added inline', str.value)
91
+ : str.removed
92
+ ? (0, utils_js_1.colorLines)('diff removed inline', str.value)
93
+ : str.value))
94
+ .join('');
95
+ // linenos
96
+ const lines = msg.split('\n');
97
+ if (lines.length > 4) {
98
+ const width = String(lines.length).length;
99
+ msg = lines
100
+ .map(function (str, i) {
101
+ return (0, utils_js_1.pad)(String(++i), width) + ' |' + ' ' + str;
102
+ })
103
+ .join('\n');
104
+ }
105
+ // legend
106
+ msg = `\n${(0, utils_js_1.color)('diff removed inline', 'actual')} ${(0, utils_js_1.color)('diff added inline', 'expected')}\n\n${msg}\n`;
107
+ // indent
108
+ msg = msg.replace(/^/gm, ' ');
109
+ const newError = new Error(err.message + msg);
110
+ newError.stack = err.stack;
111
+ return newError;
112
+ }
113
+ }
114
+ exports.default = TestStats;
package/cjs/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/cjs/utils.js ADDED
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.colorLines = exports.color = exports.pad = exports.getErrorsFromEvent = exports.sanitizeCaps = exports.sanitizeString = void 0;
7
+ const supports_color_1 = __importDefault(require("supports-color"));
8
+ const constants_js_1 = require("./constants.js");
9
+ /**
10
+ * replaces whitespaces with underscore and removes dots
11
+ * @param {string} str variable to sanitize
12
+ * @return {String} sanitized variable
13
+ */
14
+ function sanitizeString(str) {
15
+ if (!str) {
16
+ return '';
17
+ }
18
+ return String(str)
19
+ .replace(/^.*\/([^/]+)\/?$/, '$1')
20
+ .replace(/\./g, '_')
21
+ .replace(/\s/g, '')
22
+ .toLowerCase();
23
+ }
24
+ exports.sanitizeString = sanitizeString;
25
+ /**
26
+ * formats capability object into sanitized string for e.g.filenames
27
+ * @param {object} caps Selenium capabilities
28
+ */
29
+ function sanitizeCaps(caps) {
30
+ if (!caps) {
31
+ return '';
32
+ }
33
+ let result;
34
+ /**
35
+ * mobile caps
36
+ */
37
+ result = caps.deviceName
38
+ ? [
39
+ sanitizeString(caps.platformName),
40
+ sanitizeString(caps.deviceName || caps['appium:deviceName']),
41
+ sanitizeString(caps['appium:platformVersion']),
42
+ sanitizeString(caps['appium:app'])
43
+ ]
44
+ : [
45
+ sanitizeString(caps.browserName),
46
+ sanitizeString(caps.version || caps.browserVersion),
47
+ sanitizeString(caps.platform || caps.platformName),
48
+ sanitizeString(caps['appium:app'])
49
+ ];
50
+ result = result.filter(n => n !== undefined && n !== '');
51
+ return result.join('.');
52
+ }
53
+ exports.sanitizeCaps = sanitizeCaps;
54
+ /**
55
+ * Takes a event emitted by a framework and extracts
56
+ * an array of errors representing test or hook failures.
57
+ * This exists to maintain compatibility between frameworks
58
+ * with have a soft assertion model (Jasmine) and those that
59
+ * have a hard assertion model (Mocha)
60
+ * @param {*} e An event emitted by a framework adapter
61
+ */
62
+ function getErrorsFromEvent(e) {
63
+ if (e.errors) {
64
+ return e.errors;
65
+ }
66
+ if (e.error) {
67
+ return [e.error];
68
+ }
69
+ return [];
70
+ }
71
+ exports.getErrorsFromEvent = getErrorsFromEvent;
72
+ /**
73
+ * Pads the given `str` to `len`.
74
+ *
75
+ * @private
76
+ * @param {string} str
77
+ * @param {number} len
78
+ * @return {string}
79
+ */
80
+ function pad(str, len) {
81
+ return Array(len - str.length + 1).join(' ') + str;
82
+ }
83
+ exports.pad = pad;
84
+ function color(type, content) {
85
+ if (!supports_color_1.default.stdout) {
86
+ return String(content);
87
+ }
88
+ return `\u001b[${constants_js_1.COLORS[type]}m${content}\u001b[0m`;
89
+ }
90
+ exports.color = color;
91
+ /**
92
+ * Colors lines for `str`, using the color `name`.
93
+ *
94
+ * @private
95
+ * @param {string} name
96
+ * @param {string} str
97
+ * @return {string}
98
+ */
99
+ function colorLines(name, str) {
100
+ return str
101
+ .split('\n')
102
+ .map((str) => color(name, str))
103
+ .join('\n');
104
+ }
105
+ exports.colorLines = colorLines;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/reporter",
3
- "version": "8.15.0",
3
+ "version": "8.15.6",
4
4
  "description": "A WebdriverIO utility to help reporting all events",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-reporter",
@@ -25,10 +25,19 @@
25
25
  "access": "public"
26
26
  },
27
27
  "type": "module",
28
+ "main": "./cjs/index.js",
29
+ "module": "./build/index.js",
28
30
  "types": "./build/index.d.ts",
29
31
  "exports": {
30
- ".": "./build/index.js",
31
- "./package.json": "./package.json"
32
+ "./package.json": "./package.json",
33
+ ".": [
34
+ {
35
+ "types": "./build/index.d.ts",
36
+ "import": "./build/index.js",
37
+ "require": "./cjs/index.js"
38
+ },
39
+ "./cjs/index.js"
40
+ ]
32
41
  },
33
42
  "typeScriptVersion": "3.8.3",
34
43
  "dependencies": {
@@ -46,5 +55,5 @@
46
55
  "@types/tmp": "^0.2.3",
47
56
  "tmp": "^0.2.1"
48
57
  },
49
- "gitHead": "78e199c5ffd74bdf3a5576952c3834c29afa989f"
58
+ "gitHead": "c205398c7773823b1eb365a5abeadbcc2fb6b8a3"
50
59
  }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.prod.json",
3
+ "compilerOptions": {
4
+ "module": "CommonJS",
5
+ "outDir": "./cjs",
6
+ "declaration": false,
7
+ "declarationMap": false
8
+ }
9
+ }