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