allure-playwright 3.2.1 → 3.3.0
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/cjs/index.js +166 -78
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model.js.map +1 -1
- package/dist/cjs/utils.js +5 -1
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/index.js +165 -78
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model.js.map +1 -1
- package/dist/esm/utils.js +4 -0
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/index.d.ts +4 -20
- package/dist/types/model.d.ts +23 -0
- package/dist/types/utils.d.ts +2 -0
- package/package.json +4 -4
package/dist/esm/index.js
CHANGED
|
@@ -28,12 +28,9 @@ import path from "node:path";
|
|
|
28
28
|
import process from "node:process";
|
|
29
29
|
import { ContentType, LabelName, LinkType, Stage, Status } from "allure-js-commons";
|
|
30
30
|
import { extractMetadataFromString, getMessageAndTraceFromError, getMetadataLabel, hasLabel, stripAnsi } from "allure-js-commons/sdk";
|
|
31
|
-
import { ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE, ReporterRuntime, ShallowStepsStack, createDefaultWriter, createStepResult, escapeRegExp, formatLink, getEnvironmentLabels, getFrameworkLabel, getHostLabel, getLanguageLabel, getPackageLabel, getThreadLabel, getWorstTestStepResult, md5, parseTestPlan, readImageAsBase64 } from "allure-js-commons/sdk/reporter";
|
|
31
|
+
import { ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE, ReporterRuntime, ShallowStepsStack, createDefaultWriter, createStepResult, escapeRegExp, formatLink, getEnvironmentLabels, getFrameworkLabel, getHostLabel, getLanguageLabel, getPackageLabel, getThreadLabel, getWorstTestStepResult, md5, parseTestPlan, randomUuid, readImageAsBase64 } from "allure-js-commons/sdk/reporter";
|
|
32
32
|
import { allurePlaywrightLegacyApi } from "./legacy.js";
|
|
33
|
-
import { AFTER_HOOKS_ROOT_STEP_TITLE, BEFORE_HOOKS_ROOT_STEP_TITLE, isAfterHookStep, isBeforeHookStep, isDescendantOfStepWithTitle, statusToAllureStats } from "./utils.js";
|
|
34
|
-
|
|
35
|
-
// TODO: move to utils.ts
|
|
36
|
-
var diffEndRegexp = /-((expected)|(diff)|(actual))\.png$/;
|
|
33
|
+
import { AFTER_HOOKS_ROOT_STEP_TITLE, BEFORE_HOOKS_ROOT_STEP_TITLE, diffEndRegexp, isAfterHookStep, isBeforeHookStep, isDescendantOfStepWithTitle, normalizeHookTitle, statusToAllureStats } from "./utils.js";
|
|
37
34
|
var _AllureReporter_brand = /*#__PURE__*/new WeakSet();
|
|
38
35
|
export var AllureReporter = /*#__PURE__*/function () {
|
|
39
36
|
function AllureReporter(config) {
|
|
@@ -50,6 +47,8 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
50
47
|
_defineProperty(this, "attachmentSteps", new Map());
|
|
51
48
|
_defineProperty(this, "beforeHooksStepsStack", new Map());
|
|
52
49
|
_defineProperty(this, "afterHooksStepsStack", new Map());
|
|
50
|
+
_defineProperty(this, "beforeHooksAttachmentsStack", new Map());
|
|
51
|
+
_defineProperty(this, "afterHooksAttachmentsStack", new Map());
|
|
53
52
|
this.options = _objectSpread({
|
|
54
53
|
suiteTitle: true,
|
|
55
54
|
detail: true
|
|
@@ -140,7 +139,8 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
140
139
|
var titleMetadata = extractMetadataFromString(test.title);
|
|
141
140
|
var project = suite.project();
|
|
142
141
|
var testFilePath = path.relative(project === null || project === void 0 ? void 0 : project.testDir, test.location.file);
|
|
143
|
-
var
|
|
142
|
+
var relativeFileParts = testFilePath.split(path.sep);
|
|
143
|
+
var relativeFile = relativeFileParts.join("/");
|
|
144
144
|
// root > project > file path > test.describe...
|
|
145
145
|
var _suite$titlePath = suite.titlePath(),
|
|
146
146
|
_suite$titlePath2 = _toArray(_suite$titlePath),
|
|
@@ -154,7 +154,8 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
154
154
|
parameters: [],
|
|
155
155
|
steps: [],
|
|
156
156
|
testCaseId: md5(testCaseIdBase),
|
|
157
|
-
fullName: "".concat(relativeFile, ":").concat(test.location.line, ":").concat(test.location.column)
|
|
157
|
+
fullName: "".concat(relativeFile, ":").concat(test.location.line, ":").concat(test.location.column),
|
|
158
|
+
titlePath: relativeFileParts.concat.apply(relativeFileParts, _toConsumableArray(suiteTitles))
|
|
158
159
|
};
|
|
159
160
|
result.labels.push(getLanguageLabel());
|
|
160
161
|
result.labels.push(getFrameworkLabel("playwright"));
|
|
@@ -244,8 +245,14 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
244
245
|
}, {
|
|
245
246
|
key: "onStepBegin",
|
|
246
247
|
value: function onStepBegin(test, _result, step) {
|
|
248
|
+
var isRootBeforeHook = step.title === BEFORE_HOOKS_ROOT_STEP_TITLE;
|
|
249
|
+
var isRootAfterHook = step.title === AFTER_HOOKS_ROOT_STEP_TITLE;
|
|
250
|
+
var isRootHook = isRootBeforeHook || isRootAfterHook;
|
|
251
|
+
var isBeforeHookDescendant = isBeforeHookStep(step);
|
|
252
|
+
var isAfterHookDescendant = isAfterHookStep(step);
|
|
253
|
+
var isHookStep = isBeforeHookDescendant || isAfterHookDescendant;
|
|
247
254
|
var testUuid = this.allureResultsUuids.get(test.id);
|
|
248
|
-
if (step.category === "attach") {
|
|
255
|
+
if (step.category === "attach" && !isHookStep) {
|
|
249
256
|
var _this$allureRuntime, _this$attachmentSteps;
|
|
250
257
|
var currentStep = (_this$allureRuntime = this.allureRuntime) === null || _this$allureRuntime === void 0 ? void 0 : _this$allureRuntime.currentStep(testUuid);
|
|
251
258
|
this.attachmentSteps.set(testUuid, [].concat(_toConsumableArray((_this$attachmentSteps = this.attachmentSteps.get(testUuid)) !== null && _this$attachmentSteps !== void 0 ? _this$attachmentSteps : []), [currentStep]));
|
|
@@ -257,15 +264,25 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
257
264
|
var baseStep = _objectSpread(_objectSpread({}, createStepResult()), {}, {
|
|
258
265
|
name: step.title,
|
|
259
266
|
start: step.startTime.getTime(),
|
|
260
|
-
stage: Stage.RUNNING
|
|
267
|
+
stage: Stage.RUNNING,
|
|
268
|
+
uuid: randomUuid()
|
|
261
269
|
});
|
|
262
|
-
|
|
263
|
-
var isRootAfterHook = step.title === AFTER_HOOKS_ROOT_STEP_TITLE;
|
|
264
|
-
var isRootHook = isRootBeforeHook || isRootAfterHook;
|
|
265
|
-
var isBeforeHookDescendant = isBeforeHookStep(step);
|
|
266
|
-
var isAfterHookDescendant = isAfterHookStep(step);
|
|
267
|
-
if (isBeforeHookDescendant || isAfterHookDescendant) {
|
|
270
|
+
if (isHookStep) {
|
|
268
271
|
var stack = isBeforeHookDescendant ? this.beforeHooksStepsStack.get(test.id) : this.afterHooksStepsStack.get(test.id);
|
|
272
|
+
if (step.category === "attach") {
|
|
273
|
+
stack.startStep(baseStep);
|
|
274
|
+
var attachStack = isBeforeHookDescendant ? this.beforeHooksAttachmentsStack : this.afterHooksAttachmentsStack;
|
|
275
|
+
stack.updateStep(function (stepResult) {
|
|
276
|
+
var _attachStack$get;
|
|
277
|
+
stepResult.name = normalizeHookTitle(stepResult.name);
|
|
278
|
+
stepResult.stage = Stage.FINISHED;
|
|
279
|
+
attachStack.set(test.id, [].concat(_toConsumableArray((_attachStack$get = attachStack.get(test.id)) !== null && _attachStack$get !== void 0 ? _attachStack$get : []), [_objectSpread(_objectSpread({}, step), {}, {
|
|
280
|
+
uuid: stepResult.uuid
|
|
281
|
+
})]));
|
|
282
|
+
});
|
|
283
|
+
stack.stopStep();
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
269
286
|
stack.startStep(baseStep);
|
|
270
287
|
return;
|
|
271
288
|
}
|
|
@@ -287,7 +304,6 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
287
304
|
if (_assertClassBrand(_AllureReporter_brand, this, _shouldIgnoreStep).call(this, step)) {
|
|
288
305
|
return;
|
|
289
306
|
}
|
|
290
|
-
|
|
291
307
|
// ignore attach steps since attachments are already in the report
|
|
292
308
|
if (step.category === "attach") {
|
|
293
309
|
return;
|
|
@@ -341,10 +357,12 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
341
357
|
value: function () {
|
|
342
358
|
var _onTestEnd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(test, result) {
|
|
343
359
|
var _this = this,
|
|
360
|
+
_this$beforeHooksAtta,
|
|
361
|
+
_this$afterHooksAttac,
|
|
344
362
|
_this$attachmentSteps2;
|
|
345
|
-
var testUuid, threadId, thread, error, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, beforeHooksStack, afterHooksStack, attachmentSteps, i, attachment, attachmentStep;
|
|
346
|
-
return _regeneratorRuntime().wrap(function _callee$(
|
|
347
|
-
while (1) switch (
|
|
363
|
+
var testUuid, threadId, thread, error, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, beforeHooksStack, afterHooksStack, attachmentsInBeforeHooks, attachmentsInAfterHooks, hookAttachmentUuids, attachmentSteps, attachmentsInSteps, i, attachment, attachmentStep, hookAttachmentNames, onlyHooksAttachments, _iterator2, _step2, _loop;
|
|
364
|
+
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
365
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
348
366
|
case 0:
|
|
349
367
|
testUuid = this.allureResultsUuids.get(test.id); // We need to check parallelIndex first because pw introduced this field only in v1.30.0
|
|
350
368
|
threadId = result.parallelIndex !== undefined ? result.parallelIndex : result.workerIndex;
|
|
@@ -390,22 +408,30 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
390
408
|
testResult.status = statusToAllureStats(result.status, test.expectedStatus);
|
|
391
409
|
testResult.stage = Stage.FINISHED;
|
|
392
410
|
});
|
|
411
|
+
attachmentsInBeforeHooks = (_this$beforeHooksAtta = this.beforeHooksAttachmentsStack.get(test.id)) !== null && _this$beforeHooksAtta !== void 0 ? _this$beforeHooksAtta : [];
|
|
412
|
+
attachmentsInAfterHooks = (_this$afterHooksAttac = this.afterHooksAttachmentsStack.get(test.id)) !== null && _this$afterHooksAttac !== void 0 ? _this$afterHooksAttac : [];
|
|
413
|
+
hookAttachmentUuids = new Set([].concat(_toConsumableArray(attachmentsInBeforeHooks), _toConsumableArray(attachmentsInAfterHooks)).map(function (hookStep) {
|
|
414
|
+
return normalizeHookTitle(hookStep.title);
|
|
415
|
+
}).filter(Boolean));
|
|
393
416
|
attachmentSteps = (_this$attachmentSteps2 = this.attachmentSteps.get(testUuid)) !== null && _this$attachmentSteps2 !== void 0 ? _this$attachmentSteps2 : [];
|
|
417
|
+
attachmentsInSteps = result.attachments.filter(function (attachment) {
|
|
418
|
+
return !hookAttachmentUuids.has(attachment.name);
|
|
419
|
+
});
|
|
394
420
|
i = 0;
|
|
395
|
-
case
|
|
396
|
-
if (!(i <
|
|
397
|
-
|
|
421
|
+
case 14:
|
|
422
|
+
if (!(i < attachmentsInSteps.length)) {
|
|
423
|
+
_context2.next = 22;
|
|
398
424
|
break;
|
|
399
425
|
}
|
|
400
|
-
attachment =
|
|
426
|
+
attachment = attachmentsInSteps[i];
|
|
401
427
|
attachmentStep = attachmentSteps.length > i ? attachmentSteps[i] : undefined;
|
|
402
|
-
|
|
428
|
+
_context2.next = 19;
|
|
403
429
|
return this.processAttachment(testUuid, attachmentStep, attachment);
|
|
404
|
-
case
|
|
430
|
+
case 19:
|
|
405
431
|
i++;
|
|
406
|
-
|
|
432
|
+
_context2.next = 14;
|
|
407
433
|
break;
|
|
408
|
-
case
|
|
434
|
+
case 22:
|
|
409
435
|
if (result.stdout.length > 0) {
|
|
410
436
|
this.allureRuntime.writeAttachment(testUuid, undefined, "stdout", Buffer.from(stripAnsi(result.stdout.join("")), "utf-8"), {
|
|
411
437
|
contentType: ContentType.TEXT
|
|
@@ -419,6 +445,67 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
419
445
|
|
|
420
446
|
// FIXME: temp logic for labels override, we need it here to keep the reporter compatible with v2 API
|
|
421
447
|
// in next iterations we need to implement the logic for every javascript integration
|
|
448
|
+
hookAttachmentNames = new Set([].concat(_toConsumableArray(attachmentsInBeforeHooks), _toConsumableArray(attachmentsInAfterHooks)).map(function (hookStep) {
|
|
449
|
+
return normalizeHookTitle(hookStep.title);
|
|
450
|
+
}).filter(Boolean));
|
|
451
|
+
onlyHooksAttachments = result.attachments.filter(function (att) {
|
|
452
|
+
return hookAttachmentNames.has(att.name);
|
|
453
|
+
});
|
|
454
|
+
_iterator2 = _createForOfIteratorHelper(onlyHooksAttachments);
|
|
455
|
+
_context2.prev = 27;
|
|
456
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
457
|
+
var attachment, matchingBeforeHookStep, matchingAfterHookStep, targetStack, hookStep, stepResult, fileName;
|
|
458
|
+
return _regeneratorRuntime().wrap(function _loop$(_context) {
|
|
459
|
+
while (1) switch (_context.prev = _context.next) {
|
|
460
|
+
case 0:
|
|
461
|
+
attachment = _step2.value;
|
|
462
|
+
matchingBeforeHookStep = attachmentsInBeforeHooks.find(function (step) {
|
|
463
|
+
return normalizeHookTitle(step.title) === attachment.name;
|
|
464
|
+
});
|
|
465
|
+
matchingAfterHookStep = attachmentsInAfterHooks.find(function (step) {
|
|
466
|
+
return normalizeHookTitle(step.title) === attachment.name;
|
|
467
|
+
});
|
|
468
|
+
targetStack = matchingBeforeHookStep ? beforeHooksStack : afterHooksStack;
|
|
469
|
+
hookStep = matchingBeforeHookStep || matchingAfterHookStep;
|
|
470
|
+
if (targetStack && hookStep) {
|
|
471
|
+
stepResult = targetStack === null || targetStack === void 0 ? void 0 : targetStack.findStepByUuid(hookStep === null || hookStep === void 0 ? void 0 : hookStep.uuid);
|
|
472
|
+
if (stepResult) {
|
|
473
|
+
fileName = targetStack.addAttachment(attachment, _this.allureRuntime.writer);
|
|
474
|
+
stepResult.attachments.push({
|
|
475
|
+
name: attachment.name,
|
|
476
|
+
type: attachment.contentType,
|
|
477
|
+
source: fileName
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
case 6:
|
|
482
|
+
case "end":
|
|
483
|
+
return _context.stop();
|
|
484
|
+
}
|
|
485
|
+
}, _loop);
|
|
486
|
+
});
|
|
487
|
+
_iterator2.s();
|
|
488
|
+
case 30:
|
|
489
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
490
|
+
_context2.next = 34;
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
return _context2.delegateYield(_loop(), "t0", 32);
|
|
494
|
+
case 32:
|
|
495
|
+
_context2.next = 30;
|
|
496
|
+
break;
|
|
497
|
+
case 34:
|
|
498
|
+
_context2.next = 39;
|
|
499
|
+
break;
|
|
500
|
+
case 36:
|
|
501
|
+
_context2.prev = 36;
|
|
502
|
+
_context2.t1 = _context2["catch"](27);
|
|
503
|
+
_iterator2.e(_context2.t1);
|
|
504
|
+
case 39:
|
|
505
|
+
_context2.prev = 39;
|
|
506
|
+
_iterator2.f();
|
|
507
|
+
return _context2.finish(39);
|
|
508
|
+
case 42:
|
|
422
509
|
this.allureRuntime.updateTest(testUuid, function (testResult) {
|
|
423
510
|
var mappedLabels = testResult.labels.reduce(function (acc, label) {
|
|
424
511
|
if (!acc[label.name]) {
|
|
@@ -450,11 +537,11 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
450
537
|
duration: result.duration
|
|
451
538
|
});
|
|
452
539
|
this.allureRuntime.writeTest(testUuid);
|
|
453
|
-
case
|
|
540
|
+
case 45:
|
|
454
541
|
case "end":
|
|
455
|
-
return
|
|
542
|
+
return _context2.stop();
|
|
456
543
|
}
|
|
457
|
-
}, _callee, this);
|
|
544
|
+
}, _callee, this, [[27, 36, 39, 42]]);
|
|
458
545
|
}));
|
|
459
546
|
function onTestEnd(_x, _x2) {
|
|
460
547
|
return _onTestEnd.apply(this, arguments);
|
|
@@ -466,26 +553,26 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
466
553
|
value: function () {
|
|
467
554
|
var _addSkippedResults = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
468
555
|
var _this2 = this;
|
|
469
|
-
var unprocessedCases,
|
|
470
|
-
return _regeneratorRuntime().wrap(function _callee2$(
|
|
471
|
-
while (1) switch (
|
|
556
|
+
var unprocessedCases, _iterator3, _step3, testCase;
|
|
557
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context3) {
|
|
558
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
472
559
|
case 0:
|
|
473
560
|
unprocessedCases = this.suite.allTests().filter(function (_ref4) {
|
|
474
561
|
var title = _ref4.title;
|
|
475
562
|
var titleMetadata = extractMetadataFromString(title);
|
|
476
563
|
return !_this2.startedTestCasesTitlesCache.includes(titleMetadata.cleanTitle);
|
|
477
564
|
});
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
565
|
+
_iterator3 = _createForOfIteratorHelper(unprocessedCases);
|
|
566
|
+
_context3.prev = 2;
|
|
567
|
+
_iterator3.s();
|
|
481
568
|
case 4:
|
|
482
|
-
if ((
|
|
483
|
-
|
|
569
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
570
|
+
_context3.next = 11;
|
|
484
571
|
break;
|
|
485
572
|
}
|
|
486
|
-
testCase =
|
|
573
|
+
testCase = _step3.value;
|
|
487
574
|
this.onTestBegin(testCase);
|
|
488
|
-
|
|
575
|
+
_context3.next = 9;
|
|
489
576
|
return this.onTestEnd(testCase, {
|
|
490
577
|
status: Status.SKIPPED,
|
|
491
578
|
attachments: [],
|
|
@@ -500,22 +587,22 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
500
587
|
startTime: this.globalStartTime
|
|
501
588
|
});
|
|
502
589
|
case 9:
|
|
503
|
-
|
|
590
|
+
_context3.next = 4;
|
|
504
591
|
break;
|
|
505
592
|
case 11:
|
|
506
|
-
|
|
593
|
+
_context3.next = 16;
|
|
507
594
|
break;
|
|
508
595
|
case 13:
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
596
|
+
_context3.prev = 13;
|
|
597
|
+
_context3.t0 = _context3["catch"](2);
|
|
598
|
+
_iterator3.e(_context3.t0);
|
|
512
599
|
case 16:
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
return
|
|
600
|
+
_context3.prev = 16;
|
|
601
|
+
_iterator3.f();
|
|
602
|
+
return _context3.finish(16);
|
|
516
603
|
case 19:
|
|
517
604
|
case "end":
|
|
518
|
-
return
|
|
605
|
+
return _context3.stop();
|
|
519
606
|
}
|
|
520
607
|
}, _callee2, this, [[2, 13, 16, 19]]);
|
|
521
608
|
}));
|
|
@@ -528,17 +615,17 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
528
615
|
key: "onEnd",
|
|
529
616
|
value: function () {
|
|
530
617
|
var _onEnd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
531
|
-
return _regeneratorRuntime().wrap(function _callee3$(
|
|
532
|
-
while (1) switch (
|
|
618
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context4) {
|
|
619
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
533
620
|
case 0:
|
|
534
|
-
|
|
621
|
+
_context4.next = 2;
|
|
535
622
|
return this.addSkippedResults();
|
|
536
623
|
case 2:
|
|
537
624
|
this.allureRuntime.writeEnvironmentInfo();
|
|
538
625
|
this.allureRuntime.writeCategoriesDefinitions();
|
|
539
626
|
case 4:
|
|
540
627
|
case "end":
|
|
541
|
-
return
|
|
628
|
+
return _context4.stop();
|
|
542
629
|
}
|
|
543
630
|
}, _callee3, this);
|
|
544
631
|
}));
|
|
@@ -572,36 +659,36 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
572
659
|
value: function () {
|
|
573
660
|
var _processAttachment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(testUuid, attachmentStepUuid, attachment) {
|
|
574
661
|
var allureRuntimeMessage, message, parentUuid, contentType, pathWithoutEnd, actualBase64, expectedBase64, diffBase64, diffName;
|
|
575
|
-
return _regeneratorRuntime().wrap(function _callee4$(
|
|
576
|
-
while (1) switch (
|
|
662
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context5) {
|
|
663
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
577
664
|
case 0:
|
|
578
665
|
if (!(!attachment.body && !attachment.path)) {
|
|
579
|
-
|
|
666
|
+
_context5.next = 2;
|
|
580
667
|
break;
|
|
581
668
|
}
|
|
582
|
-
return
|
|
669
|
+
return _context5.abrupt("return");
|
|
583
670
|
case 2:
|
|
584
671
|
allureRuntimeMessage = attachment.contentType === ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE;
|
|
585
672
|
if (!(allureRuntimeMessage && !attachment.body)) {
|
|
586
|
-
|
|
673
|
+
_context5.next = 5;
|
|
587
674
|
break;
|
|
588
675
|
}
|
|
589
|
-
return
|
|
676
|
+
return _context5.abrupt("return");
|
|
590
677
|
case 5:
|
|
591
678
|
if (!allureRuntimeMessage) {
|
|
592
|
-
|
|
679
|
+
_context5.next = 12;
|
|
593
680
|
break;
|
|
594
681
|
}
|
|
595
682
|
message = JSON.parse(attachment.body.toString());
|
|
596
683
|
if (!(message.type === "step_metadata")) {
|
|
597
|
-
|
|
684
|
+
_context5.next = 10;
|
|
598
685
|
break;
|
|
599
686
|
}
|
|
600
687
|
this.processStepMetadataMessage(attachmentStepUuid, message);
|
|
601
|
-
return
|
|
688
|
+
return _context5.abrupt("return");
|
|
602
689
|
case 10:
|
|
603
690
|
this.allureRuntime.applyRuntimeMessages(testUuid, [message]);
|
|
604
|
-
return
|
|
691
|
+
return _context5.abrupt("return");
|
|
605
692
|
case 12:
|
|
606
693
|
parentUuid = this.allureRuntime.startStep(testUuid, attachmentStepUuid, {
|
|
607
694
|
name: attachment.name
|
|
@@ -612,20 +699,20 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
612
699
|
this.allureRuntime.stopStep(parentUuid, undefined);
|
|
613
700
|
}
|
|
614
701
|
if (!attachment.body) {
|
|
615
|
-
|
|
702
|
+
_context5.next = 18;
|
|
616
703
|
break;
|
|
617
704
|
}
|
|
618
705
|
this.allureRuntime.writeAttachment(testUuid, parentUuid, attachment.name, attachment.body, {
|
|
619
706
|
contentType: attachment.contentType
|
|
620
707
|
});
|
|
621
|
-
|
|
708
|
+
_context5.next = 24;
|
|
622
709
|
break;
|
|
623
710
|
case 18:
|
|
624
711
|
if (existsSync(attachment.path)) {
|
|
625
|
-
|
|
712
|
+
_context5.next = 22;
|
|
626
713
|
break;
|
|
627
714
|
}
|
|
628
|
-
return
|
|
715
|
+
return _context5.abrupt("return");
|
|
629
716
|
case 22:
|
|
630
717
|
contentType = attachment.name === "trace" && attachment.contentType === "application/zip" ? "application/vnd.allure.playwright-trace" : attachment.contentType;
|
|
631
718
|
this.allureRuntime.writeAttachment(testUuid, parentUuid, attachment.name, attachment.path, {
|
|
@@ -633,30 +720,30 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
633
720
|
});
|
|
634
721
|
case 24:
|
|
635
722
|
if (attachment.name.match(diffEndRegexp)) {
|
|
636
|
-
|
|
723
|
+
_context5.next = 26;
|
|
637
724
|
break;
|
|
638
725
|
}
|
|
639
|
-
return
|
|
726
|
+
return _context5.abrupt("return");
|
|
640
727
|
case 26:
|
|
641
728
|
pathWithoutEnd = attachment.path.replace(diffEndRegexp, "");
|
|
642
729
|
if (!this.processedDiffs.includes(pathWithoutEnd)) {
|
|
643
|
-
|
|
730
|
+
_context5.next = 29;
|
|
644
731
|
break;
|
|
645
732
|
}
|
|
646
|
-
return
|
|
733
|
+
return _context5.abrupt("return");
|
|
647
734
|
case 29:
|
|
648
|
-
|
|
735
|
+
_context5.next = 31;
|
|
649
736
|
return readImageAsBase64("".concat(pathWithoutEnd, "-actual.png"));
|
|
650
737
|
case 31:
|
|
651
|
-
actualBase64 =
|
|
652
|
-
|
|
738
|
+
actualBase64 = _context5.sent;
|
|
739
|
+
_context5.next = 34;
|
|
653
740
|
return readImageAsBase64("".concat(pathWithoutEnd, "-expected.png"));
|
|
654
741
|
case 34:
|
|
655
|
-
expectedBase64 =
|
|
656
|
-
|
|
742
|
+
expectedBase64 = _context5.sent;
|
|
743
|
+
_context5.next = 37;
|
|
657
744
|
return readImageAsBase64("".concat(pathWithoutEnd, "-diff.png"));
|
|
658
745
|
case 37:
|
|
659
|
-
diffBase64 =
|
|
746
|
+
diffBase64 = _context5.sent;
|
|
660
747
|
diffName = attachment.name.replace(diffEndRegexp, "");
|
|
661
748
|
this.allureRuntime.writeAttachment(testUuid, undefined, diffName, Buffer.from(JSON.stringify({
|
|
662
749
|
expected: expectedBase64,
|
|
@@ -670,7 +757,7 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
670
757
|
this.processedDiffs.push(pathWithoutEnd);
|
|
671
758
|
case 41:
|
|
672
759
|
case "end":
|
|
673
|
-
return
|
|
760
|
+
return _context5.stop();
|
|
674
761
|
}
|
|
675
762
|
}, _callee4, this);
|
|
676
763
|
}));
|