allure-playwright 3.14.0 → 3.15.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/README.md +27 -1
- package/dist/cjs/index.js +71 -29
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model.js.map +1 -1
- package/dist/cjs/utils.js +39 -3
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/index.js +73 -31
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model.js.map +1 -1
- package/dist/esm/utils.js +39 -3
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/index.d.ts +5 -1
- package/dist/types/model.d.ts +6 -0
- package/dist/types/utils.d.ts +9 -1
- package/package.json +3 -5
package/dist/cjs/utils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.statusToAllureStats = exports.normalizeHookTitle = exports.normalizeAttachStepTitle = exports.isDescendantOfStepWithTitle = exports.isBeforeHookStep = exports.isAfterHookStep = exports.getStepStatusData = exports.getSkipAnnotation = exports.finalizeStepResult = exports.diffEndRegexp = exports.BEFORE_HOOKS_ROOT_STEP_TITLE = exports.AFTER_HOOKS_ROOT_STEP_TITLE = void 0;
|
|
6
|
+
exports.statusToAllureStats = exports.normalizeHookTitle = exports.normalizeAttachStepTitle = exports.isDescendantOfStepWithTitle = exports.isBeforeHookStep = exports.isAfterHookStep = exports.getStepStatusData = exports.getStatusDetails = exports.getSkipModifierError = exports.getSkipAnnotation = exports.finalizeStepResult = exports.diffEndRegexp = exports.BEFORE_HOOKS_ROOT_STEP_TITLE = exports.AFTER_HOOKS_ROOT_STEP_TITLE = void 0;
|
|
7
7
|
var _allureJsCommons = require("allure-js-commons");
|
|
8
8
|
var _sdk = require("allure-js-commons/sdk");
|
|
9
9
|
var _syncAnnotations = require("./syncAnnotations.js");
|
|
@@ -15,6 +15,13 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
15
15
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
16
|
var AFTER_HOOKS_ROOT_STEP_TITLE = exports.AFTER_HOOKS_ROOT_STEP_TITLE = "After Hooks";
|
|
17
17
|
var BEFORE_HOOKS_ROOT_STEP_TITLE = exports.BEFORE_HOOKS_ROOT_STEP_TITLE = "Before Hooks";
|
|
18
|
+
var getStatusDetails = exports.getStatusDetails = function getStatusDetails(error) {
|
|
19
|
+
var details = (0, _sdk.getMessageAndTraceFromError)(error);
|
|
20
|
+
if (error.snippet) {
|
|
21
|
+
details.trace = [(0, _sdk.stripAnsi)(error.snippet), details.trace].filter(Boolean).join("\n\n");
|
|
22
|
+
}
|
|
23
|
+
return details;
|
|
24
|
+
};
|
|
18
25
|
var statusToAllureStats = exports.statusToAllureStats = function statusToAllureStats(status, expectedStatus) {
|
|
19
26
|
if (status === "skipped") {
|
|
20
27
|
return _allureJsCommons.Status.SKIPPED;
|
|
@@ -59,6 +66,26 @@ var getSkipAnnotation = exports.getSkipAnnotation = function getSkipAnnotation(s
|
|
|
59
66
|
return annotation.type === "skip";
|
|
60
67
|
});
|
|
61
68
|
};
|
|
69
|
+
|
|
70
|
+
// Playwright implements the test.skip() and test.fixme() modifiers by throwing an internal error with
|
|
71
|
+
// this message. When a modifier is called from a hook or from inside a step, the error is attached to
|
|
72
|
+
// the surrounding step, so a skipped test reaches the reporter with errored steps although nothing failed.
|
|
73
|
+
var SKIP_MODIFIER_ERROR_REGEXP = /^(?:\S*Error:\s)?Test is skipped:\s?([\s\S]*)$/;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Detects an error produced by a Playwright skip modifier and extracts the reason passed to it.
|
|
77
|
+
* Returns `undefined` for any other error, including a genuine failure.
|
|
78
|
+
*/
|
|
79
|
+
var getSkipModifierError = exports.getSkipModifierError = function getSkipModifierError(error) {
|
|
80
|
+
var match = error.message ? SKIP_MODIFIER_ERROR_REGEXP.exec(error.message) : null;
|
|
81
|
+
if (!match) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
var reason = match[1].trim();
|
|
85
|
+
return reason ? {
|
|
86
|
+
reason: reason
|
|
87
|
+
} : {};
|
|
88
|
+
};
|
|
62
89
|
var getStepStatusData = exports.getStepStatusData = function getStepStatusData(step) {
|
|
63
90
|
var _step$annotations$fin;
|
|
64
91
|
var annotatedStatus = (_step$annotations$fin = step.annotations.find(function (annotation) {
|
|
@@ -67,13 +94,22 @@ var getStepStatusData = exports.getStepStatusData = function getStepStatusData(s
|
|
|
67
94
|
if (annotatedStatus !== undefined) {
|
|
68
95
|
return {
|
|
69
96
|
status: annotatedStatus,
|
|
70
|
-
statusDetails: step.error ? _objectSpread({}, (
|
|
97
|
+
statusDetails: step.error ? _objectSpread({}, getStatusDetails(step.error)) : undefined
|
|
71
98
|
};
|
|
72
99
|
}
|
|
73
100
|
if (step.error) {
|
|
101
|
+
var skipModifierError = getSkipModifierError(step.error);
|
|
102
|
+
if (skipModifierError) {
|
|
103
|
+
return {
|
|
104
|
+
status: _allureJsCommons.Status.SKIPPED,
|
|
105
|
+
statusDetails: skipModifierError.reason ? {
|
|
106
|
+
message: skipModifierError.reason
|
|
107
|
+
} : undefined
|
|
108
|
+
};
|
|
109
|
+
}
|
|
74
110
|
return {
|
|
75
111
|
status: _allureJsCommons.Status.FAILED,
|
|
76
|
-
statusDetails: _objectSpread({}, (
|
|
112
|
+
statusDetails: _objectSpread({}, getStatusDetails(step.error))
|
|
77
113
|
};
|
|
78
114
|
}
|
|
79
115
|
var skipAnnotation = getSkipAnnotation(step);
|
package/dist/cjs/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["_allureJsCommons","require","_sdk","_syncAnnotations","_typeof","o","Symbol","iterator","constructor","prototype","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","toPrimitive","call","TypeError","String","Number","AFTER_HOOKS_ROOT_STEP_TITLE","exports","BEFORE_HOOKS_ROOT_STEP_TITLE","statusToAllureStats","status","expectedStatus","Status","SKIPPED","BROKEN","PASSED","FAILED","isDescendantOfStepWithTitle","step","title","parent","isAfterHookStep","isBeforeHookStep","diffEndRegexp","normalizeHookTitle","replace","normalizeAttachStepTitle","match","trim","getSkipAnnotation","annotations","find","annotation","type","getStepStatusData","_step$annotations$fin","annotatedStatus","ALLURE_STEP_STATUS_ANNOTATION","isAllureStepStatus","description","undefined","statusDetails","error","getMessageAndTraceFromError","skipAnnotation","message","finalizeStepResult","stepResult","_getStepStatusData","nextStatus","stage","Stage","FINISHED"],"sources":["../../src/utils.ts"],"sourcesContent":["import type { TestStatus } from \"@playwright/test\";\nimport type { TestStep } from \"@playwright/test/reporter\";\nimport { Stage, Status, type StatusDetails, type StepResult } from \"allure-js-commons\";\nimport { getMessageAndTraceFromError } from \"allure-js-commons/sdk\";\n\nimport { ALLURE_STEP_STATUS_ANNOTATION, isAllureStepStatus } from \"./syncAnnotations.js\";\n\nexport const AFTER_HOOKS_ROOT_STEP_TITLE = \"After Hooks\";\n\nexport const BEFORE_HOOKS_ROOT_STEP_TITLE = \"Before Hooks\";\n\nexport const statusToAllureStats = (status: TestStatus, expectedStatus: TestStatus): Status => {\n if (status === \"skipped\") {\n return Status.SKIPPED;\n }\n\n if (status === \"timedOut\") {\n return Status.BROKEN;\n }\n\n if (status === expectedStatus) {\n return Status.PASSED;\n }\n\n return Status.FAILED;\n};\n\nexport const isDescendantOfStepWithTitle = (step: TestStep, title: string): boolean => {\n let parent = step.parent;\n\n while (parent) {\n if (parent.title === title) {\n return true;\n }\n\n parent = parent.parent;\n }\n\n return false;\n};\n\nexport const isAfterHookStep = (step: TestStep) => isDescendantOfStepWithTitle(step, AFTER_HOOKS_ROOT_STEP_TITLE);\n\nexport const isBeforeHookStep = (step: TestStep) => isDescendantOfStepWithTitle(step, BEFORE_HOOKS_ROOT_STEP_TITLE);\n\nexport const diffEndRegexp = /-((expected)|(diff)|(actual))\\.(png|webp)$/;\n\nexport const normalizeHookTitle = (title: string) => {\n return title.replace(/^[aA]ttach\\s\"(.+)\"$/, \"$1\");\n};\n\nexport const normalizeAttachStepTitle = (title: string): string => {\n const match = title.match(/[\"'`]{1}(.+?)[\"'`]{1}/);\n if (match?.[1]) {\n return match[1];\n }\n return title.replace(/^(test\\.)?attach\\s*/i, \"\").trim();\n};\n\nexport const getSkipAnnotation = (step: Pick<TestStep, \"annotations\">) => {\n return step.annotations.find((annotation) => annotation.type === \"skip\");\n};\n\nexport const getStepStatusData = (\n step: Pick<TestStep, \"annotations\" | \"error\">,\n): {\n status: Status;\n statusDetails?: StatusDetails;\n} => {\n const annotatedStatus = step.annotations.find(\n (annotation) => annotation.type === ALLURE_STEP_STATUS_ANNOTATION && isAllureStepStatus(annotation.description),\n )?.description;\n\n if (annotatedStatus !== undefined) {\n return {\n status: annotatedStatus as Status,\n statusDetails: step.error ? { ...getMessageAndTraceFromError(step.error) } : undefined,\n };\n }\n\n if (step.error) {\n return {\n status: Status.FAILED,\n statusDetails: { ...getMessageAndTraceFromError(step.error) },\n };\n }\n\n const skipAnnotation = getSkipAnnotation(step);\n\n if (skipAnnotation) {\n return {\n status: Status.SKIPPED,\n statusDetails: skipAnnotation.description ? { message: skipAnnotation.description } : undefined,\n };\n }\n\n return {\n status: Status.PASSED,\n };\n};\n\nexport const finalizeStepResult = (stepResult: StepResult, step: Pick<TestStep, \"annotations\" | \"error\">) => {\n const { status: nextStatus, statusDetails } = getStepStatusData(step);\n\n stepResult.status = nextStatus;\n stepResult.stage = Stage.FINISHED;\n\n if (statusDetails) {\n // Preserve any previously collected fields and only overwrite values provided by the current step outcome.\n stepResult.statusDetails = { ...stepResult.statusDetails, ...statusDetails };\n }\n};\n"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAF,OAAA;AAAyF,SAAAG,QAAAC,CAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAF,CAAA,kBAAAA,CAAA,gBAAAA,CAAA,WAAAA,CAAA,yBAAAC,MAAA,IAAAD,CAAA,CAAAG,WAAA,KAAAF,MAAA,IAAAD,CAAA,KAAAC,MAAA,CAAAG,SAAA,qBAAAJ,CAAA,KAAAD,OAAA,CAAAC,CAAA;AAAA,SAAAK,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAX,CAAA,GAAAS,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAP,CAAA,GAAAA,CAAA,CAAAY,MAAA,WAAAL,CAAA,WAAAE,MAAA,CAAAI,wBAAA,CAAAP,CAAA,EAAAC,CAAA,EAAAO,UAAA,OAAAN,CAAA,CAAAO,IAAA,CAAAC,KAAA,CAAAR,CAAA,EAAAR,CAAA,YAAAQ,CAAA;AAAA,SAAAS,cAAAX,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAW,SAAA,CAAAC,MAAA,EAAAZ,CAAA,UAAAC,CAAA,WAAAU,SAAA,CAAAX,CAAA,IAAAW,SAAA,CAAAX,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAY,OAAA,WAAAb,CAAA,IAAAc,eAAA,CAAAf,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAa,yB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AA,KAAO,IAAAwD,gCAA2B,EAACzB,IAAI,CAACwB,KAAK,CAAC;IAC7D,CAAC;EACH;EAEA,IAAME,cAAc,GAAGf,iBAAiB,CAACX,IAAI,CAAC;EAE9C,IAAI0B,cAAc,EAAE;IAClB,OAAO;MACLlC,MAAM,EAAEE,uBAAM,CAACC,OAAO;MACtB4B,aAAa,EAAEG,cAAc,CAACL,WAAW,GAAG;QAAEM,OAAO,EAAED,cAAc,CAACL;MAAY,CAAC,GAAGC;IACxF,CAAC;EACH;EAEA,OAAO;IACL9B,MAAM,EAAEE,uBAAM,CAACG;EACjB,CAAC;AACH,CAAC;AAEM,IAAM+B,kBAAkB,GAAAvC,OAAA,CAAAuC,kBAAA,GAAG,SAArBA,kBAAkBA,CAAIC,UAAsB,EAAE7B,IAA6C,EAAK;EAC3G,IAAA8B,kBAAA,GAA8Cd,iBAAiB,CAAChB,IAAI,CAAC;IAArD+B,UAAU,GAAAD,kBAAA,CAAlBtC,MAAM;IAAc+B,aAAa,GAAAO,kBAAA,CAAbP,aAAa;EAEzCM,UAAU,CAACrC,MAAM,GAAGuC,UAAU;EAC9BF,UAAU,CAACG,KAAK,GAAGC,sBAAK,CAACC,QAAQ;EAEjC,IAAIX,aAAa,EAAE;IACjB;IACAM,UAAU,CAACN,aAAa,GAAAtD,aAAA,CAAAA,aAAA,KAAQ4D,UAAU,CAACN,aAAa,GAAKA,aAAa,CAAE;EAC9E;AACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_allureJsCommons","require","_sdk","_syncAnnotations","_typeof","o","Symbol","iterator","constructor","prototype","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","toPrimitive","call","TypeError","String","Number","AFTER_HOOKS_ROOT_STEP_TITLE","exports","BEFORE_HOOKS_ROOT_STEP_TITLE","getStatusDetails","error","details","getMessageAndTraceFromError","snippet","trace","stripAnsi","Boolean","join","statusToAllureStats","status","expectedStatus","Status","SKIPPED","BROKEN","PASSED","FAILED","isDescendantOfStepWithTitle","step","title","parent","isAfterHookStep","isBeforeHookStep","diffEndRegexp","normalizeHookTitle","replace","normalizeAttachStepTitle","match","trim","getSkipAnnotation","annotations","find","annotation","type","SKIP_MODIFIER_ERROR_REGEXP","getSkipModifierError","message","exec","undefined","reason","getStepStatusData","_step$annotations$fin","annotatedStatus","ALLURE_STEP_STATUS_ANNOTATION","isAllureStepStatus","description","statusDetails","skipModifierError","skipAnnotation","finalizeStepResult","stepResult","_getStepStatusData","nextStatus","stage","Stage","FINISHED"],"sources":["../../src/utils.ts"],"sourcesContent":["import type { TestStatus } from \"@playwright/test\";\nimport type { TestError, TestStep } from \"@playwright/test/reporter\";\nimport { Stage, Status, type StatusDetails, type StepResult } from \"allure-js-commons\";\nimport { getMessageAndTraceFromError, stripAnsi } from \"allure-js-commons/sdk\";\n\nimport { ALLURE_STEP_STATUS_ANNOTATION, isAllureStepStatus } from \"./syncAnnotations.js\";\n\nexport const AFTER_HOOKS_ROOT_STEP_TITLE = \"After Hooks\";\n\nexport const BEFORE_HOOKS_ROOT_STEP_TITLE = \"Before Hooks\";\n\nexport const getStatusDetails = (error: TestError): StatusDetails => {\n const details = getMessageAndTraceFromError(error);\n\n if (error.snippet) {\n details.trace = [stripAnsi(error.snippet), details.trace].filter(Boolean).join(\"\\n\\n\");\n }\n\n return details;\n};\n\nexport const statusToAllureStats = (status: TestStatus, expectedStatus: TestStatus): Status => {\n if (status === \"skipped\") {\n return Status.SKIPPED;\n }\n\n if (status === \"timedOut\") {\n return Status.BROKEN;\n }\n\n if (status === expectedStatus) {\n return Status.PASSED;\n }\n\n return Status.FAILED;\n};\n\nexport const isDescendantOfStepWithTitle = (step: TestStep, title: string): boolean => {\n let parent = step.parent;\n\n while (parent) {\n if (parent.title === title) {\n return true;\n }\n\n parent = parent.parent;\n }\n\n return false;\n};\n\nexport const isAfterHookStep = (step: TestStep) => isDescendantOfStepWithTitle(step, AFTER_HOOKS_ROOT_STEP_TITLE);\n\nexport const isBeforeHookStep = (step: TestStep) => isDescendantOfStepWithTitle(step, BEFORE_HOOKS_ROOT_STEP_TITLE);\n\nexport const diffEndRegexp = /-((expected)|(diff)|(actual))\\.(png|webp)$/;\n\nexport const normalizeHookTitle = (title: string) => {\n return title.replace(/^[aA]ttach\\s\"(.+)\"$/, \"$1\");\n};\n\nexport const normalizeAttachStepTitle = (title: string): string => {\n const match = title.match(/[\"'`]{1}(.+?)[\"'`]{1}/);\n if (match?.[1]) {\n return match[1];\n }\n return title.replace(/^(test\\.)?attach\\s*/i, \"\").trim();\n};\n\nexport const getSkipAnnotation = (step: Pick<TestStep, \"annotations\">) => {\n return step.annotations.find((annotation) => annotation.type === \"skip\");\n};\n\n// Playwright implements the test.skip() and test.fixme() modifiers by throwing an internal error with\n// this message. When a modifier is called from a hook or from inside a step, the error is attached to\n// the surrounding step, so a skipped test reaches the reporter with errored steps although nothing failed.\nconst SKIP_MODIFIER_ERROR_REGEXP = /^(?:\\S*Error:\\s)?Test is skipped:\\s?([\\s\\S]*)$/;\n\n/**\n * Detects an error produced by a Playwright skip modifier and extracts the reason passed to it.\n * Returns `undefined` for any other error, including a genuine failure.\n */\nexport const getSkipModifierError = (error: Pick<TestError, \"message\">): { reason?: string } | undefined => {\n const match = error.message ? SKIP_MODIFIER_ERROR_REGEXP.exec(error.message) : null;\n\n if (!match) {\n return undefined;\n }\n\n const reason = match[1].trim();\n\n return reason ? { reason } : {};\n};\n\nexport const getStepStatusData = (\n step: Pick<TestStep, \"annotations\" | \"error\">,\n): {\n status: Status;\n statusDetails?: StatusDetails;\n} => {\n const annotatedStatus = step.annotations.find(\n (annotation) => annotation.type === ALLURE_STEP_STATUS_ANNOTATION && isAllureStepStatus(annotation.description),\n )?.description;\n\n if (annotatedStatus !== undefined) {\n return {\n status: annotatedStatus as Status,\n statusDetails: step.error ? { ...getStatusDetails(step.error) } : undefined,\n };\n }\n\n if (step.error) {\n const skipModifierError = getSkipModifierError(step.error);\n\n if (skipModifierError) {\n return {\n status: Status.SKIPPED,\n statusDetails: skipModifierError.reason ? { message: skipModifierError.reason } : undefined,\n };\n }\n\n return {\n status: Status.FAILED,\n statusDetails: { ...getStatusDetails(step.error) },\n };\n }\n\n const skipAnnotation = getSkipAnnotation(step);\n\n if (skipAnnotation) {\n return {\n status: Status.SKIPPED,\n statusDetails: skipAnnotation.description ? { message: skipAnnotation.description } : undefined,\n };\n }\n\n return {\n status: Status.PASSED,\n };\n};\n\nexport const finalizeStepResult = (stepResult: StepResult, step: Pick<TestStep, \"annotations\" | \"error\">) => {\n const { status: nextStatus, statusDetails } = getStepStatusData(step);\n\n stepResult.status = nextStatus;\n stepResult.stage = Stage.FINISHED;\n\n if (statusDetails) {\n // Preserve any previously collected fields and only overwrite values provided by the current step outcome.\n stepResult.statusDetails = { ...stepResult.statusDetails, ...statusDetails };\n }\n};\n"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAF,OAAA;AAAyF,SAAAG,QAAAC,CAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAF,CAAA,kBAAAA,CAAA,gBAAAA,CAAA,WAAAA,CAAA,yBAAAC,MAAA,IAAAD,CAAA,CAAAG,WAAA,KAAAF,MAAA,IAAAD,CAAA,KAAAC,MAAA,CAAAG,SAAA,qBAAAJ,CAAA,KAAAD,OAAA,CAAAC,CAAA;AAAA,SAAAK,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAX,CAAA,GAAAS,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAP,CAAA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Aa,EAAE;IACjB;IACAI,UAAU,CAACJ,aAAa,GAAApE,aAAA,CAAAA,aAAA,KAAQwE,UAAU,CAACJ,aAAa,GAAKA,aAAa,CAAE;EAC9E;AACF,CAAC","ignoreList":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -32,10 +32,10 @@ import process from "node:process";
|
|
|
32
32
|
/* eslint max-lines: off */
|
|
33
33
|
|
|
34
34
|
import { ContentType, LabelName, LinkType, Stage, Status } from "allure-js-commons";
|
|
35
|
-
import { extractMetadataFromString,
|
|
35
|
+
import { extractMetadataFromString, getMetadataLabel, getStatusFromError, hasLabel, stripAnsi, toGlobalErrorMessage } from "allure-js-commons/sdk";
|
|
36
36
|
import { ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE, ReporterRuntime, ShallowStepsStack, createDefaultWriter, createStepResult, formatLink, getEnvironmentLabels, getFallbackTestCaseIdLabel, getFrameworkLabel, getHostLabel, includedInTestPlan, getLanguageLabel, getPackageLabel, getProjectName, getThreadLabel, md5, parseTestPlan, randomUuid, readImageAsBase64 } from "allure-js-commons/sdk/reporter";
|
|
37
37
|
import { allurePlaywrightLegacyApi } from "./legacy.js";
|
|
38
|
-
import { AFTER_HOOKS_ROOT_STEP_TITLE, BEFORE_HOOKS_ROOT_STEP_TITLE, diffEndRegexp, finalizeStepResult, isAfterHookStep, isBeforeHookStep, isDescendantOfStepWithTitle, normalizeAttachStepTitle, normalizeHookTitle, statusToAllureStats } from "./utils.js";
|
|
38
|
+
import { AFTER_HOOKS_ROOT_STEP_TITLE, BEFORE_HOOKS_ROOT_STEP_TITLE, diffEndRegexp, finalizeStepResult, getSkipModifierError, getStatusDetails, isAfterHookStep, isBeforeHookStep, isDescendantOfStepWithTitle, normalizeAttachStepTitle, normalizeHookTitle, statusToAllureStats } from "./utils.js";
|
|
39
39
|
var _AllureReporter_brand = /*#__PURE__*/new WeakSet();
|
|
40
40
|
export var AllureReporter = /*#__PURE__*/function () {
|
|
41
41
|
function AllureReporter(config) {
|
|
@@ -60,6 +60,8 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
60
60
|
_defineProperty(this, "testFullNames", new WeakMap());
|
|
61
61
|
_defineProperty(this, "emittedHookGlobalErrorKeys", new Set());
|
|
62
62
|
_defineProperty(this, "testPlan", parseTestPlan());
|
|
63
|
+
_defineProperty(this, "replayedBlobCount", 0);
|
|
64
|
+
_defineProperty(this, "activeBlobIndex", void 0);
|
|
63
65
|
this.options = _objectSpread({
|
|
64
66
|
suiteTitle: true,
|
|
65
67
|
detail: true
|
|
@@ -174,8 +176,20 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
174
176
|
key: "onConfigure",
|
|
175
177
|
value: function onConfigure(config) {
|
|
176
178
|
this.config = config;
|
|
177
|
-
this.
|
|
178
|
-
this.
|
|
179
|
+
this.replayedBlobCount = 0;
|
|
180
|
+
this.activeBlobIndex = undefined;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Playwright's v2 merge dispatcher brackets each blob with these callbacks.
|
|
184
|
+
}, {
|
|
185
|
+
key: "onReportConfigure",
|
|
186
|
+
value: function onReportConfigure() {
|
|
187
|
+
this.activeBlobIndex = ++this.replayedBlobCount;
|
|
188
|
+
}
|
|
189
|
+
}, {
|
|
190
|
+
key: "onReportEnd",
|
|
191
|
+
value: function onReportEnd() {
|
|
192
|
+
this.activeBlobIndex = undefined;
|
|
179
193
|
}
|
|
180
194
|
}, {
|
|
181
195
|
key: "onError",
|
|
@@ -192,7 +206,10 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
192
206
|
}, {
|
|
193
207
|
key: "onBegin",
|
|
194
208
|
value: function onBegin(suite) {
|
|
209
|
+
var _this$config$projects, _this$config$projects2;
|
|
195
210
|
this.suite = suite;
|
|
211
|
+
this.outputDir = (_this$config$projects = this.config.projects[0]) === null || _this$config$projects === void 0 ? void 0 : _this$config$projects.outputDir;
|
|
212
|
+
this.snapshotDir = (_this$config$projects2 = this.config.projects[0]) === null || _this$config$projects2 === void 0 ? void 0 : _this$config$projects2.snapshotDir;
|
|
196
213
|
this.emittedHookGlobalErrorKeys.clear();
|
|
197
214
|
this.allureRuntime = new ReporterRuntime(_objectSpread(_objectSpread({}, this.options), {}, {
|
|
198
215
|
writer: createDefaultWriter({
|
|
@@ -202,12 +219,13 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
202
219
|
}
|
|
203
220
|
}, {
|
|
204
221
|
key: "onTestBegin",
|
|
205
|
-
value: function onTestBegin(test) {
|
|
222
|
+
value: function onTestBegin(test, testResult) {
|
|
206
223
|
var _metadata$relativeFil, _metadata$project, _metadata$project2;
|
|
207
224
|
var metadata = this.getStaticTestMetadata(test);
|
|
208
225
|
var titlePath = metadata.projectName ? [metadata.projectName].concat(_toConsumableArray(metadata.relativeFileParts), _toConsumableArray(metadata.suiteTitles)) : (_metadata$relativeFil = metadata.relativeFileParts).concat.apply(_metadata$relativeFil, _toConsumableArray(metadata.suiteTitles));
|
|
209
226
|
var result = {
|
|
210
227
|
name: metadata.titleMetadata.cleanTitle,
|
|
228
|
+
start: testResult.startTime.getTime(),
|
|
211
229
|
labels: [].concat(_toConsumableArray(metadata.titleMetadata.labels), _toConsumableArray(getEnvironmentLabels())),
|
|
212
230
|
links: _toConsumableArray(metadata.titleMetadata.links),
|
|
213
231
|
parameters: [],
|
|
@@ -270,6 +288,9 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
270
288
|
result.labels.push(annotationLabel);
|
|
271
289
|
continue;
|
|
272
290
|
}
|
|
291
|
+
if (this.options.reportAnnotations === false) {
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
273
294
|
result.steps.push({
|
|
274
295
|
name: "".concat(annotation.type, ": ").concat(annotation.description),
|
|
275
296
|
status: Status.PASSED,
|
|
@@ -558,7 +579,7 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
558
579
|
}, {
|
|
559
580
|
key: "onStepBegin",
|
|
560
581
|
value: function onStepBegin(test, _result, step) {
|
|
561
|
-
var
|
|
582
|
+
var _assertClassBrand$cal;
|
|
562
583
|
var testUuid = this.allureResultsUuids.get(test.id);
|
|
563
584
|
if (!testUuid) {
|
|
564
585
|
// eslint-disable-next-line no-console
|
|
@@ -581,11 +602,9 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
581
602
|
uuid: randomUuid()
|
|
582
603
|
});
|
|
583
604
|
if (["test.attach", "attach"].includes(step.category) && !isHookStep) {
|
|
584
|
-
var _this$pwStepUuid$get;
|
|
585
|
-
var parent = step.parent ? (_this$pwStepUuid$get = this.pwStepUuid.get(step.parent)) !== null && _this$pwStepUuid$get !== void 0 ? _this$pwStepUuid$get : null : null;
|
|
586
605
|
this.attachmentTargetByStep.set(step, {
|
|
587
606
|
name: normalizeAttachStepTitle(step.title),
|
|
588
|
-
stepUuid:
|
|
607
|
+
stepUuid: _assertClassBrand(_AllureReporter_brand, this, _getReportedParentUuid).call(this, step)
|
|
589
608
|
});
|
|
590
609
|
return;
|
|
591
610
|
}
|
|
@@ -627,7 +646,7 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
627
646
|
}
|
|
628
647
|
return;
|
|
629
648
|
}
|
|
630
|
-
var parentUuid =
|
|
649
|
+
var parentUuid = (_assertClassBrand$cal = _assertClassBrand(_AllureReporter_brand, this, _getReportedParentUuid).call(this, step)) !== null && _assertClassBrand$cal !== void 0 ? _assertClassBrand$cal : null;
|
|
631
650
|
var createdUuid = this.allureRuntime.startStep(testUuid, parentUuid, baseStep);
|
|
632
651
|
if (createdUuid) {
|
|
633
652
|
this.pwStepUuid.set(step, createdUuid);
|
|
@@ -713,7 +732,7 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
713
732
|
var _onTestEnd = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(test, result) {
|
|
714
733
|
var _this2 = this,
|
|
715
734
|
_this$attachmentTarge2;
|
|
716
|
-
var testUuid, threadId,
|
|
735
|
+
var testUuid, threadId, blob, thread, _test$parent$titlePat, _test$parent$titlePat2, projectSuiteTitle, fileSuiteTitle, suiteTitles, beforeHooksStack, afterHooksStack, targets, targetsByName, _iterator7, _step7, _targetsByName$get, t, q, takeByName, _iterator8, _step8, attachment, isRuntimeMessage, stepInfo, _stepInfo$hookStep$uu2, _stepInfo$hookStep2, message, targetStack, _targetStack, stepUuid, _targetStack2, stepResult, fileName, _t3;
|
|
717
736
|
return _regenerator().w(function (_context3) {
|
|
718
737
|
while (1) switch (_context3.n) {
|
|
719
738
|
case 0:
|
|
@@ -728,8 +747,8 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
728
747
|
case 1:
|
|
729
748
|
// We need to check parallelIndex first because pw introduced this field only in v1.30.0
|
|
730
749
|
threadId = result.parallelIndex !== undefined ? result.parallelIndex : result.workerIndex;
|
|
731
|
-
|
|
732
|
-
|
|
750
|
+
blob = this.activeBlobIndex === undefined ? "" : "-blob-".concat(this.activeBlobIndex);
|
|
751
|
+
thread = "pid-".concat(process.pid).concat(blob, "-worker-").concat(threadId); // only apply default suites if not set by user
|
|
733
752
|
_test$parent$titlePat = test.parent.titlePath(), _test$parent$titlePat2 = _toArray(_test$parent$titlePat), projectSuiteTitle = _test$parent$titlePat2[1], fileSuiteTitle = _test$parent$titlePat2[2], suiteTitles = _test$parent$titlePat2.slice(3);
|
|
734
753
|
beforeHooksStack = this.beforeHooksStepsStack.get(test.id);
|
|
735
754
|
afterHooksStack = this.afterHooksStepsStack.get(test.id);
|
|
@@ -754,8 +773,20 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
754
773
|
value: suiteTitles.join(" > ")
|
|
755
774
|
});
|
|
756
775
|
}
|
|
757
|
-
if (
|
|
758
|
-
|
|
776
|
+
if (result.errors.length > 0) {
|
|
777
|
+
var details = result.errors.map(function (error) {
|
|
778
|
+
return getStatusDetails(error);
|
|
779
|
+
});
|
|
780
|
+
testResult.statusDetails = _objectSpread(_objectSpread({}, details[0]), {}, {
|
|
781
|
+
message: details.map(function (_ref3) {
|
|
782
|
+
var message = _ref3.message;
|
|
783
|
+
return message;
|
|
784
|
+
}).filter(Boolean).join("\n\n") || undefined,
|
|
785
|
+
trace: details.map(function (_ref4) {
|
|
786
|
+
var trace = _ref4.trace;
|
|
787
|
+
return trace;
|
|
788
|
+
}).filter(Boolean).join("\n\n") || undefined
|
|
789
|
+
});
|
|
759
790
|
} else {
|
|
760
791
|
var _test$annotations;
|
|
761
792
|
var skipReason = (_test$annotations = test.annotations) === null || _test$annotations === void 0 || (_test$annotations = _test$annotations.find(function (annotation) {
|
|
@@ -932,7 +963,7 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
932
963
|
testResult.labels = newLabels;
|
|
933
964
|
});
|
|
934
965
|
this.allureRuntime.stopTest(testUuid, {
|
|
935
|
-
|
|
966
|
+
stop: result.startTime.getTime() + result.duration
|
|
936
967
|
});
|
|
937
968
|
this.allureRuntime.writeTest(testUuid);
|
|
938
969
|
this.attachmentTargets["delete"](test.id);
|
|
@@ -951,10 +982,10 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
951
982
|
key: "emitGlobalErrorFromHookStep",
|
|
952
983
|
value: function emitGlobalErrorFromHookStep(step) {
|
|
953
984
|
var _details$message, _details$trace;
|
|
954
|
-
if (!step.error || !isGlobalErrorHookStep(step)) {
|
|
985
|
+
if (!step.error || !isGlobalErrorHookStep(step) || getSkipModifierError(step.error)) {
|
|
955
986
|
return;
|
|
956
987
|
}
|
|
957
|
-
var details =
|
|
988
|
+
var details = getStatusDetails(step.error);
|
|
958
989
|
var key = [step.title, step.startTime.getTime(), (_details$message = details.message) !== null && _details$message !== void 0 ? _details$message : "", (_details$trace = details.trace) !== null && _details$trace !== void 0 ? _details$trace : ""].join("\0");
|
|
959
990
|
if (this.emittedHookGlobalErrorKeys.has(key)) {
|
|
960
991
|
return;
|
|
@@ -971,7 +1002,7 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
971
1002
|
value: function () {
|
|
972
1003
|
var _addSkippedResults = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
973
1004
|
var _this3 = this;
|
|
974
|
-
var unprocessedCases, _iterator9, _step9, testCase, _t4;
|
|
1005
|
+
var unprocessedCases, _iterator9, _step9, testCase, result, _t4;
|
|
975
1006
|
return _regenerator().w(function (_context4) {
|
|
976
1007
|
while (1) switch (_context4.n) {
|
|
977
1008
|
case 0:
|
|
@@ -989,9 +1020,7 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
989
1020
|
break;
|
|
990
1021
|
}
|
|
991
1022
|
testCase = _step9.value;
|
|
992
|
-
|
|
993
|
-
_context4.n = 3;
|
|
994
|
-
return this.onTestEnd(testCase, {
|
|
1023
|
+
result = {
|
|
995
1024
|
status: Status.SKIPPED,
|
|
996
1025
|
attachments: [],
|
|
997
1026
|
duration: 0,
|
|
@@ -1004,7 +1033,10 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
1004
1033
|
stdout: [],
|
|
1005
1034
|
startTime: this.globalStartTime,
|
|
1006
1035
|
annotations: []
|
|
1007
|
-
}
|
|
1036
|
+
};
|
|
1037
|
+
this.onTestBegin(testCase, result);
|
|
1038
|
+
_context4.n = 3;
|
|
1039
|
+
return this.onTestEnd(testCase, result);
|
|
1008
1040
|
case 3:
|
|
1009
1041
|
_context4.n = 2;
|
|
1010
1042
|
break;
|
|
@@ -1099,11 +1131,11 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
1099
1131
|
}, {
|
|
1100
1132
|
key: "getStaticTestMetadata",
|
|
1101
1133
|
value: function getStaticTestMetadata(test) {
|
|
1102
|
-
var
|
|
1134
|
+
var _ref5, _test$parent$project, _titleMetadata$labels;
|
|
1103
1135
|
var titleMetadata = extractMetadataFromString(test.title);
|
|
1104
|
-
var project = (
|
|
1136
|
+
var project = (_ref5 = (_test$parent$project = test.parent.project()) !== null && _test$parent$project !== void 0 ? _test$parent$project : this.config.projects.find(function (candidate) {
|
|
1105
1137
|
return test.location.file === candidate.testDir || test.location.file.startsWith("".concat(candidate.testDir).concat(path.sep));
|
|
1106
|
-
})) !== null &&
|
|
1138
|
+
})) !== null && _ref5 !== void 0 ? _ref5 : this.config.projects[0];
|
|
1107
1139
|
var testFilePath = path.relative(project.testDir, test.location.file);
|
|
1108
1140
|
var relativeFileParts = testFilePath.split(path.sep);
|
|
1109
1141
|
var relativeFile = relativeFileParts.join("/");
|
|
@@ -1287,7 +1319,7 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
1287
1319
|
return _context8.a(2);
|
|
1288
1320
|
case 8:
|
|
1289
1321
|
fileExists = /*#__PURE__*/function () {
|
|
1290
|
-
var
|
|
1322
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(filePath) {
|
|
1291
1323
|
return _regenerator().w(function (_context6) {
|
|
1292
1324
|
while (1) switch (_context6.n) {
|
|
1293
1325
|
case 0:
|
|
@@ -1303,11 +1335,11 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
1303
1335
|
}, _callee6);
|
|
1304
1336
|
}));
|
|
1305
1337
|
return function fileExists(_x8) {
|
|
1306
|
-
return
|
|
1338
|
+
return _ref6.apply(this, arguments);
|
|
1307
1339
|
};
|
|
1308
1340
|
}();
|
|
1309
1341
|
readImageFromDirs = /*#__PURE__*/function () {
|
|
1310
|
-
var
|
|
1342
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(modifier) {
|
|
1311
1343
|
var defaultPath, snapshotPath;
|
|
1312
1344
|
return _regenerator().w(function (_context7) {
|
|
1313
1345
|
while (1) switch (_context7.n) {
|
|
@@ -1343,7 +1375,7 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
1343
1375
|
}, _callee7);
|
|
1344
1376
|
}));
|
|
1345
1377
|
return function readImageFromDirs(_x9) {
|
|
1346
|
-
return
|
|
1378
|
+
return _ref7.apply(this, arguments);
|
|
1347
1379
|
};
|
|
1348
1380
|
}();
|
|
1349
1381
|
_context8.n = 9;
|
|
@@ -1391,7 +1423,9 @@ export var AllureReporter = /*#__PURE__*/function () {
|
|
|
1391
1423
|
* @deprecated for removal, import functions directly from "allure-js-commons".
|
|
1392
1424
|
*/
|
|
1393
1425
|
function _shouldIgnoreStep(step) {
|
|
1394
|
-
|
|
1426
|
+
var _this$options$reportM;
|
|
1427
|
+
var detail = step.category === "expect" ? (_this$options$reportM = this.options.reportMatchers) !== null && _this$options$reportM !== void 0 ? _this$options$reportM : this.options.detail : this.options.detail;
|
|
1428
|
+
if (!detail && !["test.step", "attach", "test.attach"].includes(step.category)) {
|
|
1395
1429
|
return true;
|
|
1396
1430
|
}
|
|
1397
1431
|
|
|
@@ -1406,6 +1440,14 @@ function _shouldIgnoreStep(step) {
|
|
|
1406
1440
|
}
|
|
1407
1441
|
return false;
|
|
1408
1442
|
}
|
|
1443
|
+
function _getReportedParentUuid(step) {
|
|
1444
|
+
for (var parent = step.parent; parent; parent = parent.parent) {
|
|
1445
|
+
var uuid = this.pwStepUuid.get(parent);
|
|
1446
|
+
if (uuid !== undefined) {
|
|
1447
|
+
return uuid;
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1409
1451
|
function _getOrCreateHookStack(testId, isBeforeHook, startTime) {
|
|
1410
1452
|
var map = isBeforeHook ? this.beforeHooksStepsStack : this.afterHooksStepsStack;
|
|
1411
1453
|
var stack = map.get(testId);
|