@testream/webdriverio-reporter 0.2.0 → 0.2.1
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.
- package/dist/esm/index.mjs +6 -209
- package/package.json +2 -2
package/dist/esm/index.mjs
CHANGED
|
@@ -8,13 +8,7 @@ var __typeError = (msg) => {
|
|
|
8
8
|
throw TypeError(msg);
|
|
9
9
|
};
|
|
10
10
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
-
var
|
|
12
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
13
|
-
}) : x)(function(x) {
|
|
14
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
15
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
16
|
-
});
|
|
17
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
11
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
18
12
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
19
13
|
};
|
|
20
14
|
var __copyProps = (to, from, except, desc) => {
|
|
@@ -256,203 +250,6 @@ var require_brace_expansion = __commonJS({
|
|
|
256
250
|
}
|
|
257
251
|
});
|
|
258
252
|
|
|
259
|
-
// ../../node_modules/wdio-ctrf-json-reporter/dist/reporter.js
|
|
260
|
-
var require_reporter = __commonJS({
|
|
261
|
-
"../../node_modules/wdio-ctrf-json-reporter/dist/reporter.js"(exports) {
|
|
262
|
-
"use strict";
|
|
263
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
264
|
-
var reporter_1 = __require("@wdio/reporter");
|
|
265
|
-
var fs3 = __require("fs");
|
|
266
|
-
var path4 = __require("path");
|
|
267
|
-
var url_1 = __require("url");
|
|
268
|
-
var GenerateCtrfReport = class extends reporter_1.default {
|
|
269
|
-
constructor(options = {}) {
|
|
270
|
-
var _a3;
|
|
271
|
-
options = Object.assign({ outputDir: "ctrf", minimal: false, testType: "e2e", stdout: false }, options);
|
|
272
|
-
super(options);
|
|
273
|
-
this.currentSuite = "";
|
|
274
|
-
this.currentSpecFile = "";
|
|
275
|
-
this.currentBrowser = "";
|
|
276
|
-
this.outputDir = (_a3 = options.outputDir) !== null && _a3 !== void 0 ? _a3 : "ctrf";
|
|
277
|
-
this.reporterConfigOptions = options;
|
|
278
|
-
this.ctrfReport = {
|
|
279
|
-
results: {
|
|
280
|
-
tool: {
|
|
281
|
-
name: "webdriverio"
|
|
282
|
-
},
|
|
283
|
-
summary: {
|
|
284
|
-
tests: 0,
|
|
285
|
-
passed: 0,
|
|
286
|
-
failed: 0,
|
|
287
|
-
skipped: 0,
|
|
288
|
-
pending: 0,
|
|
289
|
-
other: 0,
|
|
290
|
-
start: 0,
|
|
291
|
-
stop: 0
|
|
292
|
-
},
|
|
293
|
-
tests: []
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
if (!fs3.existsSync(this.outputDir)) {
|
|
297
|
-
fs3.mkdirSync(this.outputDir, { recursive: true });
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
onSuiteStart(suite) {
|
|
301
|
-
this.currentSuite = suite.fullTitle;
|
|
302
|
-
this.currentSpecFile = suite.file;
|
|
303
|
-
}
|
|
304
|
-
onRunnerStart(runner) {
|
|
305
|
-
this.ctrfReport.results.summary.start = Date.now();
|
|
306
|
-
const caps = runner.capabilities;
|
|
307
|
-
if (caps === null || caps === void 0 ? void 0 : caps.browserName) {
|
|
308
|
-
this.currentBrowser = caps.browserName;
|
|
309
|
-
}
|
|
310
|
-
if (caps === null || caps === void 0 ? void 0 : caps.browserVersion) {
|
|
311
|
-
this.currentBrowser += ` ${caps.browserVersion}`;
|
|
312
|
-
}
|
|
313
|
-
this.ctrfReport.results.environment = {
|
|
314
|
-
appName: this.reporterConfigOptions.appName,
|
|
315
|
-
appVersion: this.reporterConfigOptions.appVersion,
|
|
316
|
-
osPlatform: this.reporterConfigOptions.osPlatform,
|
|
317
|
-
osRelease: this.reporterConfigOptions.osRelease,
|
|
318
|
-
osVersion: this.reporterConfigOptions.osVersion,
|
|
319
|
-
buildName: this.reporterConfigOptions.buildName,
|
|
320
|
-
buildNumber: this.reporterConfigOptions.buildNumber,
|
|
321
|
-
buildUrl: this.reporterConfigOptions.buildUrl,
|
|
322
|
-
extra: caps
|
|
323
|
-
};
|
|
324
|
-
const oldCtfFilePath = path4.join(this.outputDir, this.getReportFileName(runner.specs[0]));
|
|
325
|
-
if (fs3.existsSync(oldCtfFilePath)) {
|
|
326
|
-
try {
|
|
327
|
-
this.previousReport = JSON.parse(fs3.readFileSync(oldCtfFilePath, "utf8"));
|
|
328
|
-
} catch (e) {
|
|
329
|
-
console.error(`CTRF: Error reading previous report ${String(e)}`);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
onTestEnd(testStats) {
|
|
334
|
-
this.updateCtrfTestResultsFromTestStats(testStats, testStats.state);
|
|
335
|
-
this.updateCtrfTotalsFromTestStats(testStats);
|
|
336
|
-
}
|
|
337
|
-
getReportFileName(specFilePath) {
|
|
338
|
-
if (specFilePath.startsWith("file://")) {
|
|
339
|
-
specFilePath = (0, url_1.fileURLToPath)(specFilePath);
|
|
340
|
-
}
|
|
341
|
-
let specRelativePath = specFilePath;
|
|
342
|
-
if (specFilePath.includes(process.cwd())) {
|
|
343
|
-
specRelativePath = path4.relative(process.cwd(), specFilePath);
|
|
344
|
-
}
|
|
345
|
-
const uniqueIdentifier = specRelativePath.split(path4.sep).join("-").replace(/\.(js|ts)$/, "").replace(/[<>:"|?*]/g, "_").replace(/[\x00-\x1F]/g, "_").trim().replace(/[. ]+$/, "");
|
|
346
|
-
return `ctrf-${uniqueIdentifier}.json`;
|
|
347
|
-
}
|
|
348
|
-
onRunnerEnd(runner) {
|
|
349
|
-
this.ctrfReport.results.summary.stop = Date.now();
|
|
350
|
-
const fileName = this.getReportFileName(runner.specs[0]);
|
|
351
|
-
this.writeReportToFile(this.ctrfReport, fileName);
|
|
352
|
-
}
|
|
353
|
-
updateCtrfTotalsFromTestStats(testStats) {
|
|
354
|
-
this.ctrfReport.results.summary.tests += 1;
|
|
355
|
-
switch (testStats.state) {
|
|
356
|
-
case "passed":
|
|
357
|
-
this.ctrfReport.results.summary.passed += 1;
|
|
358
|
-
break;
|
|
359
|
-
case "failed":
|
|
360
|
-
this.ctrfReport.results.summary.failed += 1;
|
|
361
|
-
break;
|
|
362
|
-
case "skipped":
|
|
363
|
-
this.ctrfReport.results.summary.skipped += 1;
|
|
364
|
-
break;
|
|
365
|
-
case "pending":
|
|
366
|
-
this.ctrfReport.results.summary.pending += 1;
|
|
367
|
-
break;
|
|
368
|
-
default:
|
|
369
|
-
this.ctrfReport.results.summary.other += 1;
|
|
370
|
-
break;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
updateCtrfTestResultsFromTestStats(test, status) {
|
|
374
|
-
var _a3, _b3, _c2, _d2, _e2;
|
|
375
|
-
const ctrfTest = {
|
|
376
|
-
name: test.title,
|
|
377
|
-
status,
|
|
378
|
-
duration: test._duration
|
|
379
|
-
};
|
|
380
|
-
if (this.reporterConfigOptions.minimal === false) {
|
|
381
|
-
const previousTest = (_a3 = this.previousReport) === null || _a3 === void 0 ? void 0 : _a3.results.tests.find((name) => name.name === test.title);
|
|
382
|
-
ctrfTest.start = Math.floor(test.start.getTime() / 1e3);
|
|
383
|
-
ctrfTest.stop = test.end ? Math.floor(test.end.getTime() / 1e3) : 0;
|
|
384
|
-
ctrfTest.message = this.extractFailureDetails(test).message;
|
|
385
|
-
ctrfTest.trace = this.extractFailureDetails(test).trace;
|
|
386
|
-
ctrfTest.rawStatus = test.state;
|
|
387
|
-
ctrfTest.type = (_b3 = this.reporterConfigOptions.testType) !== null && _b3 !== void 0 ? _b3 : "e2e";
|
|
388
|
-
if (previousTest) {
|
|
389
|
-
if (previousTest.status === "failed") {
|
|
390
|
-
ctrfTest.retries = ((_c2 = previousTest.retries) !== null && _c2 !== void 0 ? _c2 : 0) + 1;
|
|
391
|
-
}
|
|
392
|
-
} else {
|
|
393
|
-
ctrfTest.retries = (_d2 = test.retries) !== null && _d2 !== void 0 ? _d2 : 0;
|
|
394
|
-
}
|
|
395
|
-
if (previousTest) {
|
|
396
|
-
if (previousTest.status === "failed") {
|
|
397
|
-
ctrfTest.flaky = test.state === "passed";
|
|
398
|
-
} else {
|
|
399
|
-
ctrfTest.flaky = false;
|
|
400
|
-
}
|
|
401
|
-
} else {
|
|
402
|
-
ctrfTest.flaky = test.state === "passed" && ((_e2 = test.retries) !== null && _e2 !== void 0 ? _e2 : 0) > 0;
|
|
403
|
-
}
|
|
404
|
-
ctrfTest.suite = this.currentSuite;
|
|
405
|
-
ctrfTest.filePath = this.currentSpecFile;
|
|
406
|
-
ctrfTest.browser = this.currentBrowser;
|
|
407
|
-
}
|
|
408
|
-
this.ctrfReport.results.tests.push(ctrfTest);
|
|
409
|
-
}
|
|
410
|
-
hasEnvironmentDetails(environment) {
|
|
411
|
-
return Object.keys(environment).length > 0;
|
|
412
|
-
}
|
|
413
|
-
extractFailureDetails(testResult) {
|
|
414
|
-
if (testResult.state === "failed" && testResult.error) {
|
|
415
|
-
const failureDetails = {};
|
|
416
|
-
if (testResult.error.message) {
|
|
417
|
-
failureDetails.message = testResult.error.message;
|
|
418
|
-
}
|
|
419
|
-
if (testResult.error.stack) {
|
|
420
|
-
failureDetails.trace = testResult.error.stack;
|
|
421
|
-
}
|
|
422
|
-
return failureDetails;
|
|
423
|
-
}
|
|
424
|
-
return {};
|
|
425
|
-
}
|
|
426
|
-
getReportPath(fileName) {
|
|
427
|
-
return path4.join(this.outputDir, fileName);
|
|
428
|
-
}
|
|
429
|
-
writeReportToFile(data, fileName) {
|
|
430
|
-
const filePath = this.getReportPath(fileName);
|
|
431
|
-
const str = JSON.stringify(data, null, 2);
|
|
432
|
-
try {
|
|
433
|
-
fs3.writeFileSync(filePath, str + "\n");
|
|
434
|
-
} catch (e) {
|
|
435
|
-
console.error(`CTRF: Error writing report ${String(e)}`);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
exports.default = GenerateCtrfReport;
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
|
|
443
|
-
// ../../node_modules/wdio-ctrf-json-reporter/dist/index.js
|
|
444
|
-
var require_dist = __commonJS({
|
|
445
|
-
"../../node_modules/wdio-ctrf-json-reporter/dist/index.js"(exports) {
|
|
446
|
-
"use strict";
|
|
447
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
448
|
-
exports.default = void 0;
|
|
449
|
-
var reporter_1 = require_reporter();
|
|
450
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function() {
|
|
451
|
-
return reporter_1.default;
|
|
452
|
-
} });
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
|
|
456
253
|
// ../shared-types/dist/ctrf.js
|
|
457
254
|
var require_ctrf = __commonJS({
|
|
458
255
|
"../shared-types/dist/ctrf.js"(exports) {
|
|
@@ -682,7 +479,7 @@ var require_upload = __commonJS({
|
|
|
682
479
|
});
|
|
683
480
|
|
|
684
481
|
// ../shared-types/dist/index.js
|
|
685
|
-
var
|
|
482
|
+
var require_dist = __commonJS({
|
|
686
483
|
"../shared-types/dist/index.js"(exports) {
|
|
687
484
|
"use strict";
|
|
688
485
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
@@ -7245,11 +7042,11 @@ var glob = Object.assign(glob_, {
|
|
|
7245
7042
|
glob.glob = glob;
|
|
7246
7043
|
|
|
7247
7044
|
// src/reporter.ts
|
|
7248
|
-
var
|
|
7249
|
-
|
|
7045
|
+
var import_shared_types2 = __toESM(require_dist());
|
|
7046
|
+
import WdioCtrfJsonReporter from "wdio-ctrf-json-reporter";
|
|
7250
7047
|
|
|
7251
7048
|
// src/uploader.ts
|
|
7252
|
-
var import_shared_types = __toESM(
|
|
7049
|
+
var import_shared_types = __toESM(require_dist());
|
|
7253
7050
|
async function uploadToApi(options) {
|
|
7254
7051
|
return (0, import_shared_types.uploadTestRun)({
|
|
7255
7052
|
report: options.report,
|
|
@@ -7268,7 +7065,7 @@ async function uploadToApi(options) {
|
|
|
7268
7065
|
}
|
|
7269
7066
|
|
|
7270
7067
|
// src/reporter.ts
|
|
7271
|
-
var TestreamWebdriverIOReporter = class _TestreamWebdriverIOReporter extends
|
|
7068
|
+
var TestreamWebdriverIOReporter = class _TestreamWebdriverIOReporter extends WdioCtrfJsonReporter {
|
|
7272
7069
|
constructor(options) {
|
|
7273
7070
|
const ctrfOptions = {
|
|
7274
7071
|
...options,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testream/webdriverio-reporter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "WebdriverIO reporter to upload test results to Testream",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.mjs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"build": "npm run clean && npm run build:cjs && npm run build:esm && npm run build:types",
|
|
17
17
|
"clean": "rm -rf dist",
|
|
18
18
|
"build:cjs": "ncc build src/index.ts -o dist/cjs --minify -e @wdio/reporter -e wdio-ctrf-json-reporter",
|
|
19
|
-
"build:esm": "esbuild src/index.ts --bundle --format=esm --platform=node --target=es2020 --outfile=dist/esm/index.mjs --external:@wdio/reporter --external:@wdio/types",
|
|
19
|
+
"build:esm": "esbuild src/index.ts --bundle --format=esm --platform=node --target=es2020 --outfile=dist/esm/index.mjs --external:@wdio/reporter --external:@wdio/types --external:wdio-ctrf-json-reporter",
|
|
20
20
|
"build:types": "tsc --declaration --emitDeclarationOnly --outDir dist",
|
|
21
21
|
"format": "prettier --write '**/*.ts'",
|
|
22
22
|
"lint": "eslint src/**/*.ts",
|