allure-playwright 3.14.0 → 3.16.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.
@@ -1 +1 @@
1
- {"version":3,"file":"testplan.js","names":["_reporter","require","testPlanFilter","exports","testPlan","parseTestPlan","undefined","tests","flatMap","testInfo","selector","map","pattern","replace","RegExp","concat","escapeRegExp"],"sources":["../../src/testplan.ts"],"sourcesContent":["import { escapeRegExp, parseTestPlan } from \"allure-js-commons/sdk/reporter\";\n\nexport const testPlanFilter = () => {\n const testPlan = parseTestPlan();\n if (!testPlan) {\n return undefined;\n }\n\n return testPlan.tests\n .flatMap((testInfo) => (testInfo.selector ? [testInfo.selector] : []))\n .map((selector) => {\n const pattern = selector.replace(\"#\", \" \");\n return new RegExp(`\\\\s${escapeRegExp(pattern)}$`);\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEO,IAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,SAAjBA,cAAcA,CAAA,EAAS;EAClC,IAAME,QAAQ,GAAG,IAAAC,uBAAa,EAAC,CAAC;EAChC,IAAI,CAACD,QAAQ,EAAE;IACb,OAAOE,SAAS;EAClB;EAEA,OAAOF,QAAQ,CAACG,KAAK,CAClBC,OAAO,CAAC,UAACC,QAAQ;IAAA,OAAMA,QAAQ,CAACC,QAAQ,GAAG,CAACD,QAAQ,CAACC,QAAQ,CAAC,GAAG,EAAE;EAAA,CAAC,CAAC,CACrEC,GAAG,CAAC,UAACD,QAAQ,EAAK;IACjB,IAAME,OAAO,GAAGF,QAAQ,CAACG,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;IAC1C,OAAO,IAAIC,MAAM,OAAAC,MAAA,CAAO,IAAAC,sBAAY,EAACJ,OAAO,CAAC,MAAG,CAAC;EACnD,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"testplan.js","names":["_reporter","require","testPlanFilter","exports","_testPlan$excludedTes","enableExcludedTests","arguments","length","undefined","testPlan","parseTestPlan","filters","tests","flatMap","testInfo","selector","map","pattern","replace","RegExp","concat","escapeRegExp","excludedPatterns","excludedTests","_ref","exclusionPrefix","join","filter","source"],"sources":["../../src/testplan.ts"],"sourcesContent":["import { escapeRegExp, parseTestPlan } from \"allure-js-commons/sdk/reporter\";\n\nexport const testPlanFilter = (enableExcludedTests = false) => {\n const testPlan = parseTestPlan({ enableExcludedTests });\n if (!testPlan) {\n return undefined;\n }\n\n const filters = testPlan.tests\n .flatMap((testInfo) => (testInfo.selector ? [testInfo.selector] : []))\n .map((selector) => {\n const pattern = selector.replace(\"#\", \" \");\n return new RegExp(`\\\\s${escapeRegExp(pattern)}$`);\n });\n\n if (!enableExcludedTests) {\n return filters;\n }\n\n const excludedPatterns = (testPlan.excludedTests ?? []).flatMap(({ selector }) =>\n selector ? [escapeRegExp(selector.replace(\"#\", \" \"))] : [],\n );\n if (excludedPatterns.length === 0) {\n return testPlan.tests.length === 0 ? undefined : filters;\n }\n\n const exclusionPrefix = `^(?![\\\\s\\\\S]*\\\\s(?:${excludedPatterns.join(\"|\")})$)`;\n if (testPlan.tests.length === 0) {\n return [new RegExp(`${exclusionPrefix}[\\\\s\\\\S]*$`)];\n }\n\n return filters.map((filter) => new RegExp(`${exclusionPrefix}[\\\\s\\\\S]*${filter.source}`));\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAEO,IAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,SAAjBA,cAAcA,CAAA,EAAoC;EAAA,IAAAE,qBAAA;EAAA,IAAhCC,mBAAmB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EACxD,IAAMG,QAAQ,GAAG,IAAAC,uBAAa,EAAC;IAAEL,mBAAmB,EAAnBA;EAAoB,CAAC,CAAC;EACvD,IAAI,CAACI,QAAQ,EAAE;IACb,OAAOD,S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IAAA,OAAK,IAAIR,MAAM,IAAAC,MAAA,CAAIK,eAAe,eAAAL,MAAA,CAAYO,MAAM,CAACC,MAAM,CAAE,CAAC;EAAA,EAAC;AAC3F,CAAC","ignoreList":[]}
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({}, (0, _sdk.getMessageAndTraceFromError)(step.error)) : undefined
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({}, (0, _sdk.getMessageAndTraceFromError)(step.error))
112
+ statusDetails: _objectSpread({}, getStatusDetails(step.error))
77
113
  };
78
114
  }
79
115
  var skipAnnotation = getSkipAnnotation(step);
@@ -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,EA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a,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,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ACL5B,MAAM,EAAEE,uBAAM,CAACG;EACjB,CAAC;AACH,CAAC;AAEM,IAAMkC,kBAAkB,GAAAnD,OAAA,CAAAmD,kBAAA,GAAG,SAArBA,kBAAkBA,CAAIC,UAAsB,EAAEhC,IAA6C,EAAK;EAC3G,IAAAiC,kBAAA,GAA8CX,iBAAiB,CAACtB,IAAI,CAAC;IAArDkC,UAAU,GAAAD,kBAAA,CAAlBzC,MAAM;IAAcoC,aAAa,GAAAK,kBAAA,CAAbL,aAAa;EAEzCI,UAAU,CAACxC,MAAM,GAAG0C,UAAU;EAC9BF,UAAU,CAACG,KAAK,GAAGC,sBAAK,CAACC,QAAQ;EAEjC,IAAIT,aAAa,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, getMessageAndTraceFromError, getMetadataLabel, getStatusFromError, hasLabel, stripAnsi, toGlobalErrorMessage } from "allure-js-commons/sdk";
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) {
@@ -59,7 +59,11 @@ export var AllureReporter = /*#__PURE__*/function () {
59
59
  _defineProperty(this, "pwStepUuid", new WeakMap());
60
60
  _defineProperty(this, "testFullNames", new WeakMap());
61
61
  _defineProperty(this, "emittedHookGlobalErrorKeys", new Set());
62
- _defineProperty(this, "testPlan", parseTestPlan());
62
+ _defineProperty(this, "testPlan", parseTestPlan({
63
+ enableExcludedTests: true
64
+ }));
65
+ _defineProperty(this, "replayedBlobCount", 0);
66
+ _defineProperty(this, "activeBlobIndex", void 0);
63
67
  this.options = _objectSpread({
64
68
  suiteTitle: true,
65
69
  detail: true
@@ -71,7 +75,7 @@ export var AllureReporter = /*#__PURE__*/function () {
71
75
  var _preprocess = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
72
76
  var suite, testRun, readonlyProjectNames, _iterator, _step, projectSuite, project, _iterator2, _step2, _projectSuite, _project, readonlyProject, _iterator3, _step3, test, metadata, _t, _t2;
73
77
  return _regenerator().w(function (_context) {
74
- while (1) switch (_context.n) {
78
+ while (1) switch (_context.p = _context.n) {
75
79
  case 0:
76
80
  suite = _ref.suite, testRun = _ref.testRun;
77
81
  if (this.testPlan) {
@@ -174,8 +178,20 @@ export var AllureReporter = /*#__PURE__*/function () {
174
178
  key: "onConfigure",
175
179
  value: function onConfigure(config) {
176
180
  this.config = config;
177
- this.outputDir = config.projects[0].outputDir;
178
- this.snapshotDir = config.projects[0].snapshotDir;
181
+ this.replayedBlobCount = 0;
182
+ this.activeBlobIndex = undefined;
183
+ }
184
+
185
+ // Playwright's v2 merge dispatcher brackets each blob with these callbacks.
186
+ }, {
187
+ key: "onReportConfigure",
188
+ value: function onReportConfigure() {
189
+ this.activeBlobIndex = ++this.replayedBlobCount;
190
+ }
191
+ }, {
192
+ key: "onReportEnd",
193
+ value: function onReportEnd() {
194
+ this.activeBlobIndex = undefined;
179
195
  }
180
196
  }, {
181
197
  key: "onError",
@@ -192,7 +208,10 @@ export var AllureReporter = /*#__PURE__*/function () {
192
208
  }, {
193
209
  key: "onBegin",
194
210
  value: function onBegin(suite) {
211
+ var _this$config$projects, _this$config$projects2;
195
212
  this.suite = suite;
213
+ this.outputDir = (_this$config$projects = this.config.projects[0]) === null || _this$config$projects === void 0 ? void 0 : _this$config$projects.outputDir;
214
+ this.snapshotDir = (_this$config$projects2 = this.config.projects[0]) === null || _this$config$projects2 === void 0 ? void 0 : _this$config$projects2.snapshotDir;
196
215
  this.emittedHookGlobalErrorKeys.clear();
197
216
  this.allureRuntime = new ReporterRuntime(_objectSpread(_objectSpread({}, this.options), {}, {
198
217
  writer: createDefaultWriter({
@@ -202,12 +221,13 @@ export var AllureReporter = /*#__PURE__*/function () {
202
221
  }
203
222
  }, {
204
223
  key: "onTestBegin",
205
- value: function onTestBegin(test) {
224
+ value: function onTestBegin(test, testResult) {
206
225
  var _metadata$relativeFil, _metadata$project, _metadata$project2;
207
226
  var metadata = this.getStaticTestMetadata(test);
208
227
  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
228
  var result = {
210
229
  name: metadata.titleMetadata.cleanTitle,
230
+ start: testResult.startTime.getTime(),
211
231
  labels: [].concat(_toConsumableArray(metadata.titleMetadata.labels), _toConsumableArray(getEnvironmentLabels())),
212
232
  links: _toConsumableArray(metadata.titleMetadata.links),
213
233
  parameters: [],
@@ -270,6 +290,9 @@ export var AllureReporter = /*#__PURE__*/function () {
270
290
  result.labels.push(annotationLabel);
271
291
  continue;
272
292
  }
293
+ if (this.options.reportAnnotations === false) {
294
+ continue;
295
+ }
273
296
  result.steps.push({
274
297
  name: "".concat(annotation.type, ": ").concat(annotation.description),
275
298
  status: Status.PASSED,
@@ -558,7 +581,7 @@ export var AllureReporter = /*#__PURE__*/function () {
558
581
  }, {
559
582
  key: "onStepBegin",
560
583
  value: function onStepBegin(test, _result, step) {
561
- var _this$pwStepUuid$get2;
584
+ var _assertClassBrand$cal;
562
585
  var testUuid = this.allureResultsUuids.get(test.id);
563
586
  if (!testUuid) {
564
587
  // eslint-disable-next-line no-console
@@ -581,11 +604,9 @@ export var AllureReporter = /*#__PURE__*/function () {
581
604
  uuid: randomUuid()
582
605
  });
583
606
  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
607
  this.attachmentTargetByStep.set(step, {
587
608
  name: normalizeAttachStepTitle(step.title),
588
- stepUuid: parent !== null && parent !== void 0 ? parent : undefined
609
+ stepUuid: _assertClassBrand(_AllureReporter_brand, this, _getReportedParentUuid).call(this, step)
589
610
  });
590
611
  return;
591
612
  }
@@ -627,7 +648,7 @@ export var AllureReporter = /*#__PURE__*/function () {
627
648
  }
628
649
  return;
629
650
  }
630
- var parentUuid = step.parent ? (_this$pwStepUuid$get2 = this.pwStepUuid.get(step.parent)) !== null && _this$pwStepUuid$get2 !== void 0 ? _this$pwStepUuid$get2 : null : null;
651
+ var parentUuid = (_assertClassBrand$cal = _assertClassBrand(_AllureReporter_brand, this, _getReportedParentUuid).call(this, step)) !== null && _assertClassBrand$cal !== void 0 ? _assertClassBrand$cal : null;
631
652
  var createdUuid = this.allureRuntime.startStep(testUuid, parentUuid, baseStep);
632
653
  if (createdUuid) {
633
654
  this.pwStepUuid.set(step, createdUuid);
@@ -713,9 +734,9 @@ export var AllureReporter = /*#__PURE__*/function () {
713
734
  var _onTestEnd = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(test, result) {
714
735
  var _this2 = this,
715
736
  _this$attachmentTarge2;
716
- var testUuid, threadId, thread, error, _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;
737
+ 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
738
  return _regenerator().w(function (_context3) {
718
- while (1) switch (_context3.n) {
739
+ while (1) switch (_context3.p = _context3.n) {
719
740
  case 0:
720
741
  testUuid = this.allureResultsUuids.get(test.id);
721
742
  if (testUuid) {
@@ -728,9 +749,9 @@ export var AllureReporter = /*#__PURE__*/function () {
728
749
  case 1:
729
750
  // We need to check parallelIndex first because pw introduced this field only in v1.30.0
730
751
  threadId = result.parallelIndex !== undefined ? result.parallelIndex : result.workerIndex;
731
- thread = "pid-".concat(process.pid, "-worker-").concat(threadId);
732
- error = result.error; // only apply default suites if not set by user
733
- _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);
752
+ blob = this.activeBlobIndex === undefined ? "" : "-blob-".concat(this.activeBlobIndex);
753
+ thread = "pid-".concat(process.pid).concat(blob, "-worker-").concat(threadId); // only apply default suites if not set by user
754
+ _test$parent$titlePat = test.parent.titlePath(), _test$parent$titlePat2 = _toArray(_test$parent$titlePat), projectSuiteTitle = _test$parent$titlePat2[1], fileSuiteTitle = _test$parent$titlePat2[2], suiteTitles = _arrayLikeToArray(_test$parent$titlePat2).slice(3);
734
755
  beforeHooksStack = this.beforeHooksStepsStack.get(test.id);
735
756
  afterHooksStack = this.afterHooksStepsStack.get(test.id);
736
757
  this.allureRuntime.updateTest(testUuid, function (testResult) {
@@ -754,8 +775,20 @@ export var AllureReporter = /*#__PURE__*/function () {
754
775
  value: suiteTitles.join(" > ")
755
776
  });
756
777
  }
757
- if (error) {
758
- testResult.statusDetails = _objectSpread({}, getMessageAndTraceFromError(error));
778
+ if (result.errors.length > 0) {
779
+ var details = result.errors.map(function (error) {
780
+ return getStatusDetails(error);
781
+ });
782
+ testResult.statusDetails = _objectSpread(_objectSpread({}, details[0]), {}, {
783
+ message: details.map(function (_ref3) {
784
+ var message = _ref3.message;
785
+ return message;
786
+ }).filter(Boolean).join("\n\n") || undefined,
787
+ trace: details.map(function (_ref4) {
788
+ var trace = _ref4.trace;
789
+ return trace;
790
+ }).filter(Boolean).join("\n\n") || undefined
791
+ });
759
792
  } else {
760
793
  var _test$annotations;
761
794
  var skipReason = (_test$annotations = test.annotations) === null || _test$annotations === void 0 || (_test$annotations = _test$annotations.find(function (annotation) {
@@ -932,7 +965,7 @@ export var AllureReporter = /*#__PURE__*/function () {
932
965
  testResult.labels = newLabels;
933
966
  });
934
967
  this.allureRuntime.stopTest(testUuid, {
935
- duration: result.duration
968
+ stop: result.startTime.getTime() + result.duration
936
969
  });
937
970
  this.allureRuntime.writeTest(testUuid);
938
971
  this.attachmentTargets["delete"](test.id);
@@ -951,10 +984,10 @@ export var AllureReporter = /*#__PURE__*/function () {
951
984
  key: "emitGlobalErrorFromHookStep",
952
985
  value: function emitGlobalErrorFromHookStep(step) {
953
986
  var _details$message, _details$trace;
954
- if (!step.error || !isGlobalErrorHookStep(step)) {
987
+ if (!step.error || !isGlobalErrorHookStep(step) || getSkipModifierError(step.error)) {
955
988
  return;
956
989
  }
957
- var details = getMessageAndTraceFromError(step.error);
990
+ var details = getStatusDetails(step.error);
958
991
  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
992
  if (this.emittedHookGlobalErrorKeys.has(key)) {
960
993
  return;
@@ -971,9 +1004,9 @@ export var AllureReporter = /*#__PURE__*/function () {
971
1004
  value: function () {
972
1005
  var _addSkippedResults = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
973
1006
  var _this3 = this;
974
- var unprocessedCases, _iterator9, _step9, testCase, _t4;
1007
+ var unprocessedCases, _iterator9, _step9, testCase, result, _t4;
975
1008
  return _regenerator().w(function (_context4) {
976
- while (1) switch (_context4.n) {
1009
+ while (1) switch (_context4.p = _context4.n) {
977
1010
  case 0:
978
1011
  unprocessedCases = this.suite.allTests().filter(function (testCase) {
979
1012
  var title = testCase.title;
@@ -989,9 +1022,7 @@ export var AllureReporter = /*#__PURE__*/function () {
989
1022
  break;
990
1023
  }
991
1024
  testCase = _step9.value;
992
- this.onTestBegin(testCase);
993
- _context4.n = 3;
994
- return this.onTestEnd(testCase, {
1025
+ result = {
995
1026
  status: Status.SKIPPED,
996
1027
  attachments: [],
997
1028
  duration: 0,
@@ -1004,7 +1035,10 @@ export var AllureReporter = /*#__PURE__*/function () {
1004
1035
  stdout: [],
1005
1036
  startTime: this.globalStartTime,
1006
1037
  annotations: []
1007
- });
1038
+ };
1039
+ this.onTestBegin(testCase, result);
1040
+ _context4.n = 3;
1041
+ return this.onTestEnd(testCase, result);
1008
1042
  case 3:
1009
1043
  _context4.n = 2;
1010
1044
  break;
@@ -1099,11 +1133,11 @@ export var AllureReporter = /*#__PURE__*/function () {
1099
1133
  }, {
1100
1134
  key: "getStaticTestMetadata",
1101
1135
  value: function getStaticTestMetadata(test) {
1102
- var _ref3, _test$parent$project, _titleMetadata$labels;
1136
+ var _ref5, _test$parent$project, _titleMetadata$labels;
1103
1137
  var titleMetadata = extractMetadataFromString(test.title);
1104
- var project = (_ref3 = (_test$parent$project = test.parent.project()) !== null && _test$parent$project !== void 0 ? _test$parent$project : this.config.projects.find(function (candidate) {
1138
+ 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
1139
  return test.location.file === candidate.testDir || test.location.file.startsWith("".concat(candidate.testDir).concat(path.sep));
1106
- })) !== null && _ref3 !== void 0 ? _ref3 : this.config.projects[0];
1140
+ })) !== null && _ref5 !== void 0 ? _ref5 : this.config.projects[0];
1107
1141
  var testFilePath = path.relative(project.testDir, test.location.file);
1108
1142
  var relativeFileParts = testFilePath.split(path.sep);
1109
1143
  var relativeFile = relativeFileParts.join("/");
@@ -1163,20 +1197,31 @@ export var AllureReporter = /*#__PURE__*/function () {
1163
1197
  key: "isInTestPlan",
1164
1198
  value: function isInTestPlan(test) {
1165
1199
  var metadata = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getStaticTestMetadata(test);
1166
- if (!this.testPlan) {
1200
+ var testPlan = this.testPlan;
1201
+ if (!testPlan) {
1167
1202
  return true;
1168
1203
  }
1169
1204
  var fullName = metadata.fullName,
1170
1205
  locationFullName = metadata.locationFullName,
1171
1206
  legacyFullName = metadata.legacyFullName,
1172
1207
  staticAllureId = metadata.staticAllureId;
1173
- return includedInTestPlan(this.testPlan, {
1208
+ var subjects = [{
1174
1209
  fullName: locationFullName,
1175
1210
  nativeSelector: fullName,
1176
1211
  id: staticAllureId
1177
- }) || includedInTestPlan(this.testPlan, {
1212
+ }, {
1178
1213
  fullName: legacyFullName,
1179
1214
  id: staticAllureId
1215
+ }];
1216
+ var exclusionPlan = _objectSpread(_objectSpread({}, testPlan), {}, {
1217
+ tests: []
1218
+ });
1219
+ return subjects.some(function (subject) {
1220
+ return includedInTestPlan(testPlan, subject);
1221
+ }) && subjects.every(function (subject) {
1222
+ return includedInTestPlan(exclusionPlan, subject, {
1223
+ enableExcludedTests: true
1224
+ });
1180
1225
  });
1181
1226
  }
1182
1227
  }, {
@@ -1287,7 +1332,7 @@ export var AllureReporter = /*#__PURE__*/function () {
1287
1332
  return _context8.a(2);
1288
1333
  case 8:
1289
1334
  fileExists = /*#__PURE__*/function () {
1290
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(filePath) {
1335
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(filePath) {
1291
1336
  return _regenerator().w(function (_context6) {
1292
1337
  while (1) switch (_context6.n) {
1293
1338
  case 0:
@@ -1303,11 +1348,11 @@ export var AllureReporter = /*#__PURE__*/function () {
1303
1348
  }, _callee6);
1304
1349
  }));
1305
1350
  return function fileExists(_x8) {
1306
- return _ref4.apply(this, arguments);
1351
+ return _ref6.apply(this, arguments);
1307
1352
  };
1308
1353
  }();
1309
1354
  readImageFromDirs = /*#__PURE__*/function () {
1310
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(modifier) {
1355
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(modifier) {
1311
1356
  var defaultPath, snapshotPath;
1312
1357
  return _regenerator().w(function (_context7) {
1313
1358
  while (1) switch (_context7.n) {
@@ -1343,7 +1388,7 @@ export var AllureReporter = /*#__PURE__*/function () {
1343
1388
  }, _callee7);
1344
1389
  }));
1345
1390
  return function readImageFromDirs(_x9) {
1346
- return _ref5.apply(this, arguments);
1391
+ return _ref7.apply(this, arguments);
1347
1392
  };
1348
1393
  }();
1349
1394
  _context8.n = 9;
@@ -1391,7 +1436,9 @@ export var AllureReporter = /*#__PURE__*/function () {
1391
1436
  * @deprecated for removal, import functions directly from "allure-js-commons".
1392
1437
  */
1393
1438
  function _shouldIgnoreStep(step) {
1394
- if (!this.options.detail && !["test.step", "attach", "test.attach"].includes(step.category)) {
1439
+ var _this$options$reportM;
1440
+ 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;
1441
+ if (!detail && !["test.step", "attach", "test.attach"].includes(step.category)) {
1395
1442
  return true;
1396
1443
  }
1397
1444
 
@@ -1406,6 +1453,14 @@ function _shouldIgnoreStep(step) {
1406
1453
  }
1407
1454
  return false;
1408
1455
  }
1456
+ function _getReportedParentUuid(step) {
1457
+ for (var parent = step.parent; parent; parent = parent.parent) {
1458
+ var uuid = this.pwStepUuid.get(parent);
1459
+ if (uuid !== undefined) {
1460
+ return uuid;
1461
+ }
1462
+ }
1463
+ }
1409
1464
  function _getOrCreateHookStack(testId, isBeforeHook, startTime) {
1410
1465
  var map = isBeforeHook ? this.beforeHooksStepsStack : this.afterHooksStepsStack;
1411
1466
  var stack = map.get(testId);