allure-cypress 3.0.5 → 3.0.7

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.
Files changed (98) hide show
  1. package/README.md +52 -77
  2. package/dist/cjs/browser/commandLog.js +216 -0
  3. package/dist/cjs/browser/commandLog.js.map +1 -0
  4. package/dist/cjs/browser/events/cypress.js +45 -0
  5. package/dist/cjs/browser/events/cypress.js.map +1 -0
  6. package/dist/cjs/browser/events/index.js +23 -0
  7. package/dist/cjs/browser/events/index.js.map +1 -0
  8. package/dist/cjs/browser/events/mocha.js +76 -0
  9. package/dist/cjs/browser/events/mocha.js.map +1 -0
  10. package/dist/cjs/browser/index.js +18 -0
  11. package/dist/cjs/browser/index.js.map +1 -0
  12. package/dist/cjs/browser/lifecycle.js +243 -0
  13. package/dist/cjs/browser/lifecycle.js.map +1 -0
  14. package/dist/cjs/browser/patching.js +126 -0
  15. package/dist/cjs/browser/patching.js.map +1 -0
  16. package/dist/cjs/browser/runtime.js +214 -0
  17. package/dist/cjs/browser/runtime.js.map +1 -0
  18. package/dist/cjs/browser/serialize.js +44 -0
  19. package/dist/cjs/browser/serialize.js.map +1 -0
  20. package/dist/cjs/browser/state.js +84 -0
  21. package/dist/cjs/browser/state.js.map +1 -0
  22. package/dist/cjs/browser/steps.js +130 -0
  23. package/dist/cjs/browser/steps.js.map +1 -0
  24. package/dist/cjs/browser/testplan.js +63 -0
  25. package/dist/cjs/browser/testplan.js.map +1 -0
  26. package/dist/cjs/browser/utils.js +153 -0
  27. package/dist/cjs/browser/utils.js.map +1 -0
  28. package/dist/cjs/index.js +1 -1
  29. package/dist/cjs/index.js.map +4 -4
  30. package/dist/cjs/reporter.js +75 -34
  31. package/dist/cjs/reporter.js.map +1 -1
  32. package/dist/cjs/types.js +2 -0
  33. package/dist/cjs/types.js.map +1 -0
  34. package/dist/cjs/utils.js +19 -173
  35. package/dist/cjs/utils.js.map +1 -1
  36. package/dist/esm/browser/commandLog.js +205 -0
  37. package/dist/esm/browser/commandLog.js.map +1 -0
  38. package/dist/esm/browser/events/cypress.js +37 -0
  39. package/dist/esm/browser/events/cypress.js.map +1 -0
  40. package/dist/esm/browser/events/index.js +11 -0
  41. package/dist/esm/browser/events/index.js.map +1 -0
  42. package/dist/esm/browser/events/mocha.js +68 -0
  43. package/dist/esm/browser/events/mocha.js.map +1 -0
  44. package/dist/esm/browser/index.js +11 -0
  45. package/dist/esm/browser/index.js.map +1 -0
  46. package/dist/esm/browser/lifecycle.js +218 -0
  47. package/dist/esm/browser/lifecycle.js.map +1 -0
  48. package/dist/esm/browser/patching.js +119 -0
  49. package/dist/esm/browser/patching.js.map +1 -0
  50. package/dist/esm/browser/runtime.js +206 -0
  51. package/dist/esm/browser/runtime.js.map +1 -0
  52. package/dist/esm/browser/serialize.js +36 -0
  53. package/dist/esm/browser/serialize.js.map +1 -0
  54. package/dist/esm/{state.js → browser/state.js} +20 -2
  55. package/dist/esm/browser/state.js.map +1 -0
  56. package/dist/esm/browser/steps.js +114 -0
  57. package/dist/esm/browser/steps.js.map +1 -0
  58. package/dist/esm/browser/testplan.js +56 -0
  59. package/dist/esm/browser/testplan.js.map +1 -0
  60. package/dist/esm/browser/utils.js +130 -0
  61. package/dist/esm/browser/utils.js.map +1 -0
  62. package/dist/esm/index.js +1 -1
  63. package/dist/esm/index.js.map +4 -4
  64. package/dist/esm/reporter.js +75 -34
  65. package/dist/esm/reporter.js.map +1 -1
  66. package/dist/esm/types.js +2 -0
  67. package/dist/esm/types.js.map +1 -0
  68. package/dist/esm/utils.js +15 -157
  69. package/dist/esm/utils.js.map +1 -1
  70. package/dist/types/browser/commandLog.d.ts +10 -0
  71. package/dist/types/browser/events/cypress.d.ts +2 -0
  72. package/dist/types/browser/events/index.d.ts +2 -0
  73. package/dist/types/browser/events/mocha.d.ts +3 -0
  74. package/dist/types/browser/index.d.ts +1 -0
  75. package/dist/types/browser/lifecycle.d.ts +22 -0
  76. package/dist/types/browser/patching.d.ts +5 -0
  77. package/dist/types/browser/runtime.d.ts +26 -0
  78. package/dist/types/browser/serialize.d.ts +2 -0
  79. package/dist/types/{state.d.ts → browser/state.d.ts} +11 -1
  80. package/dist/types/browser/steps.d.ts +14 -0
  81. package/dist/types/browser/testplan.d.ts +2 -0
  82. package/dist/types/browser/utils.d.ts +52 -0
  83. package/dist/types/reporter.d.ts +1 -1
  84. package/dist/types/{model.d.ts → types.d.ts} +61 -11
  85. package/dist/types/utils.d.ts +9 -43
  86. package/package.json +16 -11
  87. package/dist/cjs/model.js +0 -9
  88. package/dist/cjs/model.js.map +0 -1
  89. package/dist/cjs/runtime.js +0 -649
  90. package/dist/cjs/runtime.js.map +0 -1
  91. package/dist/cjs/state.js +0 -56
  92. package/dist/cjs/state.js.map +0 -1
  93. package/dist/esm/model.js +0 -3
  94. package/dist/esm/model.js.map +0 -1
  95. package/dist/esm/runtime.js +0 -620
  96. package/dist/esm/runtime.js.map +0 -1
  97. package/dist/esm/state.js.map +0 -1
  98. package/dist/types/runtime.d.ts +0 -50
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["_allureJsCommons","require","_sdk","_model","_state","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","DEFAULT_RUNTIME_CONFIG","exports","stepsFromCommands","maxArgumentLength","maxArgumentDepth","uint8ArrayToBase64","data","u8arrayLike","Array","isArray","buffer","btoa","fromCharCode","getSuites","test","suites","s","parent","reverse","getSuitePath","title","map","shouldCommandBeSkipped","command","_last","last","attributes","args","log","name","ALLURE_REPORT_STEP_COMMAND","toReversed","arr","result","resolveSpecRelativePath","spec","projectDir","getProjectDir","specPath","absolute","substring","relative","win","Cypress","platform","replaceAll","getNamesAndLabels","rawName","cleanTitle","labels","extractMetadataFromString","titlePath","slice","fullNameSuffix","concat","join","getTestStartData","_test$wallClockStarte","start","wallClockStartedAt","getTime","Date","now","getTestStopData","_test$duration","_retries","duration","retries","getTestSkipData","statusDetails","message","applyTestPlan","root","testPlan","getAllureTestPlan","suite","iterateSuites","indicesToRemove","getIndicesOfDeselectedTests","tests","removeSortedIndices","resolveStatusWithDetails","error","status","getStatusFromError","getMessageAndTraceFromError","Status","PASSED","testReportedKey","markTestAsReported","isTestReported","suiteStack","pop","iterateTests","isAllureHook","hook","includes","ALLURE_REPORT_SYSTEM_HOOK","isRootAfterAllHook","hookName","includedInTestPlan","fullName","allureId","some","_test$id","id","toString","selector","index","_labels$find","find","_ref","LabelName","ALLURE_ID","indices","splice"],"sources":["../../src/utils.ts"],"sourcesContent":["import { LabelName, Status } from \"allure-js-commons\";\nimport { extractMetadataFromString, getMessageAndTraceFromError, getStatusFromError } from \"allure-js-commons/sdk\";\nimport type { TestPlanV1 } from \"allure-js-commons/sdk\";\nimport { ALLURE_REPORT_STEP_COMMAND, ALLURE_REPORT_SYSTEM_HOOK } from \"./model.js\";\nimport type { CypressCommand, CypressHook, CypressSuite, CypressTest } from \"./model.js\";\nimport { getAllureTestPlan, getProjectDir } from \"./state.js\";\n\nexport const DEFAULT_RUNTIME_CONFIG = {\n stepsFromCommands: {\n maxArgumentLength: 128,\n maxArgumentDepth: 3,\n },\n};\n\nexport const uint8ArrayToBase64 = (data: unknown) => {\n // @ts-ignore\n const u8arrayLike = Array.isArray(data) || data.buffer;\n\n if (!u8arrayLike) {\n return data as string;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n return btoa(String.fromCharCode.apply(null, data as number[]));\n};\n\nexport const getSuites = (test: CypressTest) => {\n const suites: CypressSuite[] = [];\n for (let s: CypressSuite | undefined = test.parent; s; s = s.parent) {\n suites.push(s);\n }\n suites.reverse();\n return suites;\n};\n\nexport const getSuitePath = (test: CypressTest): string[] =>\n getSuites(test)\n .filter((s) => s.title)\n .map((s) => s.title);\n\nexport const shouldCommandBeSkipped = (command: CypressCommand) => {\n if (last(command.attributes.args)?.log === false) {\n return true;\n }\n\n if (command.attributes.name === \"task\" && command.attributes.args[0] === \"reportAllureRuntimeMessages\") {\n return true;\n }\n\n // we don't need to report then commands because it's just a promise handle\n if (command.attributes.name === \"then\") {\n return true;\n }\n\n // we should skip artificial wrap from allure steps\n if (command.attributes.name === \"wrap\" && command.attributes.args[0] === ALLURE_REPORT_STEP_COMMAND) {\n return true;\n }\n\n return false;\n};\n\nexport const toReversed = <T = unknown>(arr: T[]): T[] => {\n const result: T[] = [];\n\n for (let i = arr.length - 1; i >= 0; i--) {\n result.push(arr[i]);\n }\n\n return result;\n};\n\nexport const last = <T = unknown>(arr: T[]): T | undefined => {\n return arr[arr.length - 1];\n};\n\nconst resolveSpecRelativePath = (spec: Cypress.Spec) => {\n const projectDir = getProjectDir();\n const specPath = projectDir ? spec.absolute.substring(projectDir.length + 1) : spec.relative;\n const win = Cypress.platform === \"win32\";\n return win ? specPath.replaceAll(\"\\\\\", \"/\") : specPath;\n};\n\nexport const getNamesAndLabels = (spec: Cypress.Spec, test: CypressTest) => {\n const rawName = test.title;\n const { cleanTitle: name, labels } = extractMetadataFromString(rawName);\n const suites = test.titlePath().slice(0, -1);\n const fullNameSuffix = `${[...suites, name].join(\" \")}`;\n return { name, labels, fullNameSuffix };\n};\n\nexport const getTestStartData = (test: CypressTest) => ({\n ...getNamesAndLabels(Cypress.spec, test),\n start: test.wallClockStartedAt?.getTime() || Date.now(),\n});\n\nexport const getTestStopData = (test: CypressTest) => ({\n duration: test.duration ?? 0,\n retries: (test as any)._retries ?? 0,\n});\n\nexport const getTestSkipData = () => ({\n statusDetails: { message: \"This is a pending test\" },\n});\n\nexport const applyTestPlan = (spec: Cypress.Spec, root: CypressSuite) => {\n const testPlan = getAllureTestPlan();\n if (testPlan) {\n const specPath = resolveSpecRelativePath(spec);\n for (const suite of iterateSuites(root)) {\n const indicesToRemove = getIndicesOfDeselectedTests(testPlan, spec, specPath, suite.tests);\n removeSortedIndices(suite.tests, indicesToRemove);\n }\n }\n};\n\nexport const resolveStatusWithDetails = (error: Error | undefined) =>\n error\n ? {\n status: getStatusFromError(error),\n statusDetails: getMessageAndTraceFromError(error),\n }\n : { status: Status.PASSED };\n\nconst testReportedKey = Symbol(\"The test was reported to Allure\");\n\nexport const markTestAsReported = (test: CypressTest) => {\n (test as any)[testReportedKey] = true;\n};\n\nexport const isTestReported = (test: CypressTest) => (test as any)[testReportedKey] === true;\n\nexport const iterateSuites = function* (parent: CypressSuite) {\n const suiteStack: CypressSuite[] = [];\n for (let s: CypressSuite | undefined = parent; s; s = suiteStack.pop()) {\n yield s;\n\n // Pushing in reverse allows us to maintain depth-first pre-order traversal -\n // the same order as used by Mocha & Cypress.\n for (let i = s.suites.length - 1; i >= 0; i--) {\n suiteStack.push(s.suites[i]);\n }\n }\n};\n\nexport const iterateTests = function* (parent: CypressSuite) {\n for (const suite of iterateSuites(parent)) {\n yield* suite.tests;\n }\n};\n\nexport const isAllureHook = (hook: CypressHook) => hook.title.includes(ALLURE_REPORT_SYSTEM_HOOK);\n\nexport const isRootAfterAllHook = (hook: CypressHook) => hook.parent!.root && hook.hookName === \"after all\";\n\nconst includedInTestPlan = (testPlan: TestPlanV1, fullName: string, allureId: string | undefined): boolean =>\n testPlan.tests.some((test) => (allureId && test.id?.toString() === allureId) || test.selector === fullName);\n\nconst getIndicesOfDeselectedTests = (\n testPlan: TestPlanV1,\n spec: Cypress.Spec,\n specPath: string,\n tests: readonly CypressTest[],\n) => {\n const indicesToRemove: number[] = [];\n tests.forEach((test, index) => {\n const { fullNameSuffix, labels } = getNamesAndLabels(spec, test);\n const fullName = `${specPath}#${fullNameSuffix}`;\n const allureId = labels.find(({ name }) => name === LabelName.ALLURE_ID)?.value;\n\n if (!includedInTestPlan(testPlan, fullName, allureId)) {\n indicesToRemove.push(index);\n }\n });\n return indicesToRemove;\n};\n\nconst removeSortedIndices = <T>(arr: T[], indices: readonly number[]) =>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A,IAAAC,YAAA;IAC7B,IAAM;MAAExD,cAAc;MAAEJ;IAAO,CAAC,GAAGH,iBAAiB,CAACX,IAAI,EAAErB,IAAI,CAAC;IAChE,IAAMuF,QAAQ,MAAA/C,MAAA,CAAMhB,QAAQ,OAAAgB,MAAA,CAAID,cAAc,CAAE;IAChD,IAAMiD,QAAQ,IAAAO,YAAA,GAAG5D,MAAM,CAAC6D,IAAI,CAACC,IAAA;MAAA,IAAC;QAAElF;MAAK,CAAC,GAAAkF,IAAA;MAAA,OAAKlF,IAAI,KAAKmF,0BAAS,CAACC,SAAS;IAAA,EAAC,cAAAJ,YAAA,uBAAvDA,YAAA,CAAyDxH,KAAK;IAE/E,IAAI,CAAC+G,kBAAkB,CAAC3B,QAAQ,EAAE4B,QAAQ,EAAEC,QAAQ,CAAC,EAAE;MACrDzB,eAAe,CAACnG,IAAI,CAACkI,KAAK,CAAC;IAC7B;EACF,CAAC,CAAC;EACF,OAAO/B,eAAe;AACxB,CAAC;AAED,IAAMG,mBAAmB,GAAGA,CAAIhD,GAAQ,EAAEkF,OAA0B,KAAK;EACvE,KAAK,IAAI1H,CAAC,GAAG0H,OAAO,CAACpI,MAAM,GAAG,CAAC,EAAEU,CAAC,IAAI,CAAC,EAAEA,CAAC,EAAE,EAAE;IAC5CwC,GAAG,CAACmF,MAAM,CAACD,OAAO,CAAC1H,CAAC,CAAC,EAAE,CAAC,CAAC;EAC3B;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils.js","names":["DEFAULT_RUNTIME_CONFIG","exports","stepsFromCommands","maxArgumentLength","maxArgumentDepth","popUntilFindIncluded","items","pred","index","findIndex","toReversed","splice","arr","len","length","result","Array","i","last","isDefined","value"],"sources":["../../src/utils.ts"],"sourcesContent":["export const DEFAULT_RUNTIME_CONFIG = {\n stepsFromCommands: {\n maxArgumentLength: 128,\n maxArgumentDepth: 3,\n },\n};\n\n/**\n * Pops items from an array into a new one. The item that matches the predicate is the last item to pop.\n * If there is no such item in the array, the array is left unmodified.\n * @param items An array to pop the items from.\n * @param pred A predicate that defines the last item to pop.\n * @returns An array of popped items. The first popped item becomes the first element of this array.\n */\nexport const popUntilFindIncluded = <T>(items: T[], pred: (value: T) => boolean) => {\n const index = items.findIndex(pred);\n return index !== -1 ? toReversed(items.splice(index)) : [];\n};\n\nexport const toReversed = <T = unknown>(arr: T[]): T[] => {\n const len = arr.length;\n const result: T[] = new Array(len);\n\n for (let i = 0; i < len; i++) {\n result[len - i - 1] = arr[i];\n }\n\n return result;\n};\n\nexport const last = <T = unknown>(arr: T[]): T | undefined => {\n return arr[arr.length - 1];\n};\n\nexport const isDefined = <T>(value: T | undefined): value is T => typeof value !== \"undefined\";\n"],"mappings":";;;;;;AAAO,IAAMA,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG;EACpCE,iBAAiB,EAAE;IACjBC,iBAAiB,EAAE,GAAG;IACtBC,gBAAgB,EAAE;EACpB;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMC,oBAAoB,GAAGA,CAAIC,KAAU,EAAEC,IAA2B,KAAK;EAClF,IAAMC,KAAK,GAAGF,KAAK,CAACG,SAAS,CAACF,IAAI,CAAC;EACnC,OAAOC,KAAK,KAAK,CAAC,CAAC,GAAGE,UAAU,CAACJ,KAAK,CAACK,MAAM,CAACH,KAAK,CAAC,CAAC,GAAG,EAAE;AAC5D,CAAC;AAACP,OAAA,CAAAI,oBAAA,GAAAA,oBAAA;AAEK,IAAMK,UAAU,GAAiBE,GAAQ,IAAU;EACxD,IAAMC,GAAG,GAAGD,GAAG,CAACE,MAAM;EACtB,IAAMC,MAAW,GAAG,IAAIC,KAAK,CAACH,GAAG,CAAC;EAElC,KAAK,IAAII,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,GAAG,EAAEI,CAAC,EAAE,EAAE;IAC5BF,MAAM,CAACF,GAAG,GAAGI,CAAC,GAAG,CAAC,CAAC,GAAGL,GAAG,CAACK,CAAC,CAAC;EAC9B;EAEA,OAAOF,MAAM;AACf,CAAC;AAACd,OAAA,CAAAS,UAAA,GAAAA,UAAA;AAEK,IAAMQ,IAAI,GAAiBN,GAAQ,IAAoB;EAC5D,OAAOA,GAAG,CAACA,GAAG,CAACE,MAAM,GAAG,CAAC,CAAC;AAC5B,CAAC;AAACb,OAAA,CAAAiB,IAAA,GAAAA,IAAA;AAEK,IAAMC,SAAS,GAAOC,KAAoB,IAAiB,OAAOA,KAAK,KAAK,WAAW;AAACnB,OAAA,CAAAkB,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -0,0 +1,205 @@
1
+ import { isDefined } from "../utils.js";
2
+ import { reportStepStart } from "./lifecycle.js";
3
+ import serializePropValue from "./serialize.js";
4
+ import { getCurrentStep, getStepStack, pushStep, setupStepFinalization } from "./state.js";
5
+ import { ALLURE_STEP_CMD_SUBJECT, findAndStopStepWithSubsteps, isLogStep } from "./steps.js";
6
+ export var shouldCreateStepFromCommandLogEntry = entry => {
7
+ var {
8
+ event,
9
+ instrument
10
+ } = entry.attributes;
11
+ if (instrument !== "command") {
12
+ // We are interested in the "TEST BODY" panel only for now.
13
+ // Other instruments are logged in separate panels.
14
+ return false;
15
+ }
16
+ if (event) {
17
+ // Events are tricky to report as they may span across commands and even leave the test's scope.
18
+ // We ignore them for now.
19
+ return false;
20
+ }
21
+ if (isApiStepErrorLogEntry(entry)) {
22
+ // Cypress don't create a log message for 'cy.then' except when it throws an error.
23
+ // This is in particularly happens when the function passed to 'allure.step' throws. In such a case however,
24
+ // creating an extra step from the log entry is redundant because the error is already included in the report as
25
+ // a part of the step.
26
+ return false;
27
+ }
28
+ return true;
29
+ };
30
+
31
+ /**
32
+ * Checks if the current step represents a cy.screenshot command log entry. If this is the case, associates the name
33
+ * of the screenshot with the step. Later, that will allow converting the step with the attachment into the attachment
34
+ * step.
35
+ */
36
+ export var setupScreenshotAttachmentStep = (originalName, name) => {
37
+ var step = getCurrentStep();
38
+ if (step && isLogStep(step)) {
39
+ var {
40
+ name: commandName,
41
+ props: {
42
+ name: nameFromProps
43
+ }
44
+ } = step.log.attributes.consoleProps();
45
+ if (commandName === "screenshot" && nameFromProps === originalName) {
46
+ step.attachmentName = name;
47
+ }
48
+ }
49
+ };
50
+ export var startCommandLogStep = entry => {
51
+ var currentLogEntry = getCurrentLogEntry();
52
+ if (typeof currentLogEntry !== "undefined" && shouldStopCurrentLogStep(currentLogEntry.log, entry)) {
53
+ stopCommandLogStep(currentLogEntry.log.attributes.id);
54
+ }
55
+ pushLogEntry(entry);
56
+ reportStepStart(entry.attributes.id, getCommandLogStepName(entry));
57
+ scheduleCommandLogStepStop(entry);
58
+ };
59
+ export var stopCommandLogStep = entryId => findAndStopStepWithSubsteps(_ref => {
60
+ var {
61
+ id
62
+ } = _ref;
63
+ return id === entryId;
64
+ });
65
+ var pushLogEntry = entry => {
66
+ var id = entry.attributes.id;
67
+ var stepDescriptor = {
68
+ id,
69
+ type: "log",
70
+ log: entry
71
+ };
72
+ pushStep(stepDescriptor);
73
+
74
+ // Some properties of some Command Log entries are undefined at the time the entry is stopped. An example is the
75
+ // Yielded property of some queries. We defer converting them to Allure step parameters until the test/hook ends.
76
+ setupStepFinalization(stepDescriptor, data => {
77
+ data.parameters = getCommandLogStepParameters(entry);
78
+ if (stepDescriptor.attachmentName) {
79
+ // Rename the step to match the attachment name. Once the names are the same, Allure will render the
80
+ // attachment in the place of the step.
81
+ data.name = stepDescriptor.attachmentName;
82
+ }
83
+ });
84
+ };
85
+ var scheduleCommandLogStepStop = entry => {
86
+ var {
87
+ groupStart,
88
+ end,
89
+ id
90
+ } = entry.attributes;
91
+ if (end) {
92
+ // Some entries are already completed (this is similar to the idea behind allure.logStep).
93
+ // Cypress won't call entry.end() in such a case, so we need to stop such a step now.
94
+ // Example: cy.log
95
+ stopCommandLogStep(id);
96
+ } else if (groupStart) {
97
+ // A logging group must be stopped be the user via the Cypress.Log.endGroup() call.
98
+ // If the call is missing, the corresponding step will be stopped either at the test's (the hook's) end.
99
+ var originalEndGroup = entry.endGroup;
100
+ entry.endGroup = function () {
101
+ stopCommandLogStep(id);
102
+ return originalEndGroup.call(this);
103
+ };
104
+ } else {
105
+ // Regular log entries are finalized by Cypress via the Cypress.Log.end() call. We're hooking into this function
106
+ // to complete the step at the same time.
107
+ // eslint-disable-next-line @typescript-eslint/unbound-method
108
+ var originalEnd = entry.end;
109
+ entry.end = function () {
110
+ stopCommandLogStep(id);
111
+ return originalEnd.call(this);
112
+ };
113
+ }
114
+ };
115
+ var isApiStepErrorLogEntry = _ref2 => {
116
+ var {
117
+ attributes: {
118
+ name,
119
+ consoleProps
120
+ }
121
+ } = _ref2;
122
+ return name === "then" && Object.is(consoleProps().props["Applied To"], ALLURE_STEP_CMD_SUBJECT);
123
+ };
124
+ var getCommandLogStepName = entry => {
125
+ var _ref3, _ref4, _maybeGetAssertionLog;
126
+ var {
127
+ name,
128
+ message,
129
+ displayName
130
+ } = entry.attributes;
131
+ var resolvedName = (displayName !== null && displayName !== void 0 ? displayName : name).trim();
132
+ var resolvedMessage = ((_ref3 = (_ref4 = (_maybeGetAssertionLog = maybeGetAssertionLogMessage(entry)) !== null && _maybeGetAssertionLog !== void 0 ? _maybeGetAssertionLog : maybeGetCucumberLogMessage(entry)) !== null && _ref4 !== void 0 ? _ref4 : entry.attributes.renderProps().message) !== null && _ref3 !== void 0 ? _ref3 : message).trim();
133
+ var stepName = [resolvedName, resolvedMessage].filter(Boolean).join(" ");
134
+ return stepName;
135
+ };
136
+ var getCommandLogStepParameters = entry => getLogProps(entry).map(_ref5 => {
137
+ var [k, v] = _ref5;
138
+ return {
139
+ name: k.toString(),
140
+ value: serializePropValue(v)
141
+ };
142
+ }).filter(getPropValueSetFilter(entry));
143
+ var WELL_KNOWN_CUCUMBER_LOG_NAMES = ["Given", "When", "Then", "And"];
144
+ var maybeGetCucumberLogMessage = entry => {
145
+ var {
146
+ attributes: {
147
+ name,
148
+ message
149
+ }
150
+ } = entry;
151
+ if (WELL_KNOWN_CUCUMBER_LOG_NAMES.includes(name.trim()) && message.startsWith("**") && message.endsWith("**")) {
152
+ return message.substring(2, message.length - 2);
153
+ }
154
+ };
155
+ var getLogProps = entry => {
156
+ var {
157
+ attributes: {
158
+ consoleProps
159
+ }
160
+ } = entry;
161
+ var isAssertionWithMessage = !!maybeGetAssertionLogMessage(entry);
162
+
163
+ // For assertion logs, we interpolate the 'Message' property, which contains unformatted assertion description,
164
+ // directly into the step's name.
165
+ // No need to keep the exact same information in the step's parameters.
166
+ return Object.entries(consoleProps().props).filter(_ref6 => {
167
+ var [k, v] = _ref6;
168
+ return isDefined(v) && !(isAssertionWithMessage && k === "Message");
169
+ });
170
+ };
171
+ var maybeGetAssertionLogMessage = entry => {
172
+ if (isAssertLog(entry)) {
173
+ var message = entry.attributes.consoleProps().props.Message;
174
+ if (message && typeof message === "string") {
175
+ return message;
176
+ }
177
+ }
178
+ };
179
+ var isAssertLog = _ref7 => {
180
+ var {
181
+ attributes: {
182
+ name
183
+ }
184
+ } = _ref7;
185
+ return name === "assert";
186
+ };
187
+ var getCurrentLogEntry = () => getStepStack().findLast(isLogStep);
188
+ var shouldStopCurrentLogStep = (currentLogEntry, newLogEntry) => {
189
+ var {
190
+ groupStart: currentEntryIsGroup,
191
+ type: currentEntryType
192
+ } = currentLogEntry.attributes;
193
+ var {
194
+ type: newEntryType
195
+ } = newLogEntry.attributes;
196
+ return !currentEntryIsGroup && (currentEntryType === "child" || newEntryType !== "child");
197
+ };
198
+ var getPropValueSetFilter = entry => entry.attributes.name === "wrap" ? () => true : _ref8 => {
199
+ var {
200
+ name,
201
+ value
202
+ } = _ref8;
203
+ return name !== "Yielded" || value !== "{}";
204
+ };
205
+ //# sourceMappingURL=commandLog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandLog.js","names":["isDefined","reportStepStart","serializePropValue","getCurrentStep","getStepStack","pushStep","setupStepFinalization","ALLURE_STEP_CMD_SUBJECT","findAndStopStepWithSubsteps","isLogStep","shouldCreateStepFromCommandLogEntry","entry","event","instrument","attributes","isApiStepErrorLogEntry","setupScreenshotAttachmentStep","originalName","name","step","commandName","props","nameFromProps","log","consoleProps","attachmentName","startCommandLogStep","currentLogEntry","getCurrentLogEntry","shouldStopCurrentLogStep","stopCommandLogStep","id","pushLogEntry","getCommandLogStepName","scheduleCommandLogStepStop","entryId","_ref","stepDescriptor","type","data","parameters","getCommandLogStepParameters","groupStart","end","originalEndGroup","endGroup","call","originalEnd","_ref2","Object","is","_ref3","_ref4","_maybeGetAssertionLog","message","displayName","resolvedName","trim","resolvedMessage","maybeGetAssertionLogMessage","maybeGetCucumberLogMessage","renderProps","stepName","filter","Boolean","join","getLogProps","map","_ref5","k","v","toString","value","getPropValueSetFilter","WELL_KNOWN_CUCUMBER_LOG_NAMES","includes","startsWith","endsWith","substring","length","isAssertionWithMessage","entries","_ref6","isAssertLog","Message","_ref7","findLast","newLogEntry","currentEntryIsGroup","currentEntryType","newEntryType","_ref8"],"sources":["../../../src/browser/commandLog.ts"],"sourcesContent":["import type { Parameter } from \"allure-js-commons\";\nimport type { CypressLogEntry, LogStepDescriptor } from \"../types.js\";\nimport { isDefined } from \"../utils.js\";\nimport { reportStepStart } from \"./lifecycle.js\";\nimport serializePropValue from \"./serialize.js\";\nimport { getCurrentStep, getStepStack, pushStep, setupStepFinalization } from \"./state.js\";\nimport { ALLURE_STEP_CMD_SUBJECT, findAndStopStepWithSubsteps, isLogStep } from \"./steps.js\";\n\nexport const shouldCreateStepFromCommandLogEntry = (entry: CypressLogEntry) => {\n const { event, instrument } = entry.attributes;\n if (instrument !== \"command\") {\n // We are interested in the \"TEST BODY\" panel only for now.\n // Other instruments are logged in separate panels.\n return false;\n }\n\n if (event) {\n // Events are tricky to report as they may span across commands and even leave the test's scope.\n // We ignore them for now.\n return false;\n }\n\n if (isApiStepErrorLogEntry(entry)) {\n // Cypress don't create a log message for 'cy.then' except when it throws an error.\n // This is in particularly happens when the function passed to 'allure.step' throws. In such a case however,\n // creating an extra step from the log entry is redundant because the error is already included in the report as\n // a part of the step.\n return false;\n }\n\n return true;\n};\n\n/**\n * Checks if the current step represents a cy.screenshot command log entry. If this is the case, associates the name\n * of the screenshot with the step. Later, that will allow converting the step with the attachment into the attachment\n * step.\n */\nexport const setupScreenshotAttachmentStep = (originalName: string | undefined, name: string) => {\n const step = getCurrentStep();\n if (step && isLogStep(step)) {\n const {\n name: commandName,\n props: { name: nameFromProps },\n } = step.log.attributes.consoleProps();\n if (commandName === \"screenshot\" && nameFromProps === originalName) {\n step.attachmentName = name;\n }\n }\n};\n\nexport const startCommandLogStep = (entry: CypressLogEntry) => {\n const currentLogEntry = getCurrentLogEntry();\n if (typeof currentLogEntry !== \"undefined\" && shouldStopCurrentLogStep(currentLogEntry.log, entry)) {\n stopCommandLogStep(currentLogEntry.log.attributes.id);\n }\n\n pushLogEntry(entry);\n reportStepStart(entry.attributes.id, getCommandLogStepName(entry));\n scheduleCommandLogStepStop(entry);\n};\n\nexport const stopCommandLogStep = (entryId: string) => findAndStopStepWithSubsteps(({ id }) => id === entryId);\n\nconst pushLogEntry = (entry: CypressLogEntry) => {\n const id = entry.attributes.id;\n const stepDescriptor: LogStepDescriptor = { id, type: \"log\", log: entry };\n pushStep(stepDescriptor);\n\n // Some properties of some Command Log entries are undefined at the time the entry is stopped. An example is the\n // Yielded property of some queries. We defer converting them to Allure step parameters until the test/hook ends.\n setupStepFinalization(stepDescriptor, (data) => {\n data.parameters = getCommandLogStepParameters(entry);\n if (stepDescriptor.attachmentName) {\n // Rename the step to match the attachment name. Once the names are the same, Allure will render the\n // attachment in the place of the step.\n data.name = stepDescriptor.attachmentName;\n }\n });\n};\n\nconst scheduleCommandLogStepStop = (entry: CypressLogEntry) => {\n const { groupStart, end, id } = entry.attributes;\n if (end) {\n // Some entries are already completed (this is similar to the idea behind allure.logStep).\n // Cypress won't call entry.end() in such a case, so we need to stop such a step now.\n // Example: cy.log\n stopCommandLogStep(id);\n } else if (groupStart) {\n // A logging group must be stopped be the user via the Cypress.Log.endGroup() call.\n // If the call is missing, the corresponding step will be stopped either at the test's (the hook's) end.\n const originalEndGroup = entry.endGroup;\n entry.endGroup = function () {\n stopCommandLogStep(id);\n return originalEndGroup.call(this);\n };\n } else {\n // Regular log entries are finalized by Cypress via the Cypress.Log.end() call. We're hooking into this function\n // to complete the step at the same time.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalEnd = entry.end;\n entry.end = function () {\n stopCommandLogStep(id);\n return originalEnd.call(this);\n };\n }\n};\n\nconst isApiStepErrorLogEntry = ({ attributes: { name, consoleProps } }: CypressLogEntry) =>\n name === \"then\" && Object.is(consoleProps().props[\"Applied To\"], ALLURE_STEP_CMD_SUBJECT);\n\nconst getCommandLogStepName = (entry: CypressLogEntry) => {\n const { name, message, displayName } = entry.attributes;\n const resolvedName = (displayName ?? name).trim();\n const resolvedMessage = (\n maybeGetAssertionLogMessage(entry) ??\n maybeGetCucumberLogMessage(entry) ??\n entry.attributes.renderProps().message ??\n message\n ).trim();\n const stepName = [resolvedName, resolvedMessage].filter(Boolean).join(\" \");\n return stepName;\n};\n\nconst getCommandLogStepParameters = (entry: CypressLogEntry) =>\n getLogProps(entry)\n .map(([k, v]) => ({\n name: k.toString(),\n value: serializePropValue(v),\n }))\n .filter(getPropValueSetFilter(entry));\n\nconst WELL_KNOWN_CUCUMBER_LOG_NAMES = [\"Given\", \"When\", \"Then\", \"And\"];\n\nconst maybeGetCucumberLogMessage = (entry: CypressLogEntry) => {\n const {\n attributes: { name, message },\n } = entry;\n if (WELL_KNOWN_CUCUMBER_LOG_NAMES.includes(name.trim()) && message.startsWith(\"**\") && message.endsWith(\"**\")) {\n return message.substring(2, message.length - 2);\n }\n};\n\nconst getLogProps = (entry: CypressLogEntry) => {\n const {\n attributes: { consoleProps },\n } = entry;\n const isAssertionWithMessage = !!maybeGetAssertionLogMessage(entry);\n\n // For assertion logs, we interpolate the 'Message' property, which contains unformatted assertion description,\n // directly into the step's name.\n // No need to keep the exact same information in the step's parameters.\n return Object.entries(consoleProps().props).filter(\n ([k, v]) => isDefined(v) && !(isAssertionWithMessage && k === \"Message\"),\n );\n};\n\nconst maybeGetAssertionLogMessage = (entry: CypressLogEntry) => {\n if (isAssertLog(entry)) {\n const message = entry.attributes.consoleProps().props.Message;\n if (message && typeof message === \"string\") {\n return message;\n }\n }\n};\n\nconst isAssertLog = ({ attributes: { name } }: CypressLogEntry) => name === \"assert\";\n\nconst getCurrentLogEntry = () => getStepStack().findLast(isLogStep);\n\nconst shouldStopCurrentLogStep = (currentLogEntry: CypressLogEntry, newLogEntry: CypressLogEntry) => {\n const { groupStart: currentEntryIsGroup, type: currentEntryType } = currentLogEntry.attributes;\n const { type: newEntryType } = newLogEntry.attributes;\n\n return !currentEntryIsGroup && (currentEntryType === \"child\" || newEntryType !== \"child\");\n};\n\nconst getPropValueSetFilter = (entry: CypressLogEntry) =>\n entry.attributes.name === \"wrap\" ? () => true : ({ name, value }: Parameter) => name !== \"Yielded\" || value !== \"{}\";\n"],"mappings":"AAEA,SAASA,SAAS,QAAQ,aAAa;AACvC,SAASC,eAAe,QAAQ,gBAAgB;AAChD,OAAOC,kBAAkB,MAAM,gBAAgB;AAC/C,SAASC,cAAc,EAAEC,YAAY,EAAEC,QAAQ,EAAEC,qBAAqB,QAAQ,YAAY;AAC1F,SAASC,uBAAuB,EAAEC,2BAA2B,EAAEC,SAAS,QAAQ,YAAY;AAE5F,OAAO,IAAMC,mCAAmC,GAAIC,KAAsB,IAAK;EAC7E,IAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,KAAK,CAACG,UAAU;EAC9C,IAAID,UAAU,KAAK,SAAS,EAAE;IAC5B;IACA;IACA,OAAO,KAAK;EACd;EAEA,IAAID,KAAK,EAAE;IACT;IACA;IACA,OAAO,KAAK;EACd;EAEA,IAAIG,sBAAsB,CAACJ,KAAK,CAAC,EAAE;IACjC;IACA;IACA;IACA;IACA,OAAO,KAAK;EACd;EAEA,OAAO,IAAI;AACb,CAAC;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GAAGE,KAAA;EAAA,IAAC;IAAEvE,UAAU,EAAE;MAAEI;IAAK;EAAmB,CAAC,GAAAmE,KAAA;EAAA,OAAKnE,IAAI,KAAK,QAAQ;AAAA;AAEpF,IAAMU,kBAAkB,GAAGA,CAAA,KAAMxB,YAAY,CAAC,CAAC,CAACkF,QAAQ,CAAC7E,SAAS,CAAC;AAEnE,IAAMoB,wBAAwB,GAAGA,CAACF,eAAgC,EAAE4D,WAA4B,KAAK;EACnG,IAAM;IAAE7C,UAAU,EAAE8C,mBAAmB;IAAElD,IAAI,EAAEmD;EAAiB,CAAC,GAAG9D,eAAe,CAACb,UAAU;EAC9F,IAAM;IAAEwB,IAAI,EAAEoD;EAAa,CAAC,GAAGH,WAAW,CAACzE,UAAU;EAErD,OAAO,CAAC0E,mBAAmB,KAAKC,gBAAgB,KAAK,OAAO,IAAIC,YAAY,KAAK,OAAO,CAAC;AAC3F,CAAC;AAED,IAAMjB,qBAAqB,GAAI9D,KAAsB,IACnDA,KAAK,CAACG,UAAU,CAACI,IAAI,KAAK,MAAM,GAAG,MAAM,IAAI,GAAGyE,KAAA;EAAA,IAAC;IAAEzE,IAAI;IAAEsD;EAAiB,CAAC,GAAAmB,KAAA;EAAA,OAAKzE,IAAI,KAAK,SAAS,IAAIsD,KAAK,KAAK,IAAI;AAAA","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ import { setupScreenshotAttachmentStep, shouldCreateStepFromCommandLogEntry, startCommandLogStep } from "../commandLog.js";
2
+ import { reportScreenshot } from "../lifecycle.js";
3
+ import { reportStepError } from "../steps.js";
4
+ import { getFileNameFromPath } from "../utils.js";
5
+ export var registerCypressEventListeners = () => Cypress.on("fail", onFail).on("log:added", onLogAdded);
6
+ export var enableReportingOfCypressScreenshots = () => Cypress.Screenshot.defaults({
7
+ onAfterScreenshot
8
+ });
9
+ var onAfterScreenshot = function onAfterScreenshot() {
10
+ for (var _len = arguments.length, _ref = new Array(_len), _key = 0; _key < _len; _key++) {
11
+ _ref[_key] = arguments[_key];
12
+ }
13
+ var [, {
14
+ name: originalName,
15
+ path
16
+ }] = _ref;
17
+ var name = originalName !== null && originalName !== void 0 ? originalName : getFileNameFromPath(path);
18
+ reportScreenshot(path, name);
19
+ setupScreenshotAttachmentStep(originalName, name);
20
+ };
21
+ var onLogAdded = (_, entry) => {
22
+ if (shouldCreateStepFromCommandLogEntry(entry)) {
23
+ startCommandLogStep(entry);
24
+ }
25
+ };
26
+ var onFail = error => {
27
+ reportStepError(error);
28
+
29
+ // If there are more "fail" handlers yet to run, it's not our responsibility to throw.
30
+ // Otherwise, we won't give them any chance to do their job (EventEmitter stops executing handlers as soon
31
+ // as one of them throws - that is also true for eventemitter2, which is used by the browser-side of Cypress).
32
+ if (noSubsequentFailListeners()) {
33
+ throw error;
34
+ }
35
+ };
36
+ var noSubsequentFailListeners = () => Object.is(Cypress.listeners("fail").at(-1), onFail);
37
+ //# sourceMappingURL=cypress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cypress.js","names":["setupScreenshotAttachmentStep","shouldCreateStepFromCommandLogEntry","startCommandLogStep","reportScreenshot","reportStepError","getFileNameFromPath","registerCypressEventListeners","Cypress","on","onFail","onLogAdded","enableReportingOfCypressScreenshots","Screenshot","defaults","onAfterScreenshot","_len","arguments","length","_ref","Array","_key","name","originalName","path","_","entry","error","noSubsequentFailListeners","Object","is","listeners","at"],"sources":["../../../../src/browser/events/cypress.ts"],"sourcesContent":["import type { CypressLogEntry } from \"../../types.js\";\nimport {\n setupScreenshotAttachmentStep,\n shouldCreateStepFromCommandLogEntry,\n startCommandLogStep,\n} from \"../commandLog.js\";\nimport { reportScreenshot } from \"../lifecycle.js\";\nimport { reportStepError } from \"../steps.js\";\nimport { getFileNameFromPath } from \"../utils.js\";\n\nexport const registerCypressEventListeners = () => Cypress.on(\"fail\", onFail).on(\"log:added\", onLogAdded);\n\nexport const enableReportingOfCypressScreenshots = () => Cypress.Screenshot.defaults({ onAfterScreenshot });\n\nconst onAfterScreenshot = (\n ...[, { name: originalName, path }]: Parameters<Cypress.ScreenshotDefaultsOptions[\"onAfterScreenshot\"]>\n) => {\n const name = originalName ?? getFileNameFromPath(path);\n reportScreenshot(path, name);\n setupScreenshotAttachmentStep(originalName, name);\n};\n\nconst onLogAdded = (_: Cypress.ObjectLike, entry: CypressLogEntry) => {\n if (shouldCreateStepFromCommandLogEntry(entry)) {\n startCommandLogStep(entry);\n }\n};\n\nconst onFail = (error: Cypress.CypressError) => {\n reportStepError(error);\n\n // If there are more \"fail\" handlers yet to run, it's not our responsibility to throw.\n // Otherwise, we won't give them any chance to do their job (EventEmitter stops executing handlers as soon\n // as one of them throws - that is also true for eventemitter2, which is used by the browser-side of Cypress).\n if (noSubsequentFailListeners()) {\n throw error;\n }\n};\n\nconst noSubsequentFailListeners = () => Object.is(Cypress.listeners(\"fail\").at(-1), onFail);\n"],"mappings":"AACA,SACEA,6BAA6B,EAC7BC,mCAAmC,EACnCC,mBAAmB,QACd,kBAAkB;AACzB,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,eAAe,QAAQ,aAAa;AAC7C,SAASC,mBAAmB,QAAQ,aAAa;AAEjD,OAAO,IAAMC,6BAA6B,GAAGA,CAAA,KAAMC,OAAO,CAACC,EAAE,CAAC,MAAM,EAAEC,MAAM,CAAC,CAACD,EAAE,CAAC,WAAW,EAAEE,UAAU,CAAC;AAEzG,OAAO,IAAMC,mCAAmC,GAAGA,CAAA,KAAMJ,OAAO,CAACK,UAAU,CAACC,QAAQ,CAAC;EAAEC;AAAkB,CAAC,CAAC;AAE3G,IAAMA,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAA,EAElB;EAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAC,IAAA,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAAF,IAAA,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;EAAA;EAAA,IADA,GAAG;IAAEC,IAAI,EAAEC,YAAY;IAAEC;EAAK,CAAC,CAAC,GAAAL,IAAA;EAEnC,IAAMG,IAAI,GAAGC,YAAY,aAAZA,YAAY,cAAZA,YAAY,GAAIjB,mBAAmB,CAACkB,IAAI,CAAC;EACtDpB,gBAAgB,CAACoB,IAAI,EAAEF,IAAI,CAAC;EAC5BrB,6BAA6B,CAACsB,YAAY,EAAED,IAAI,CAAC;AACnD,CAAC;AAED,IAAMX,UAAU,GAAGA,CAACc,CAAqB,EAAEC,KAAsB,KAAK;EACpE,IAAIxB,mCAAmC,CAACwB,KAAK,CAAC,EAAE;IAC9CvB,mBAAmB,CAACuB,KAAK,CAAC;EAC5B;AACF,CAAC;AAED,IAAMhB,MAAM,GAAIiB,KAA2B,IAAK;EAC9CtB,eAAe,CAACsB,KAAK,CAAC;;EAEtB;EACA;EACA;EACA,IAAIC,yBAAyB,CAAC,CAAC,EAAE;IAC/B,MAAMD,KAAK;EACb;AACF,CAAC;AAED,IAAMC,yBAAyB,GAAGA,CAAA,KAAMC,MAAM,CAACC,EAAE,CAACtB,OAAO,CAACuB,SAAS,CAAC,MAAM,CAAC,CAACC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAEtB,MAAM,CAAC","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import { enableScopeLevelAfterHookReporting } from "../patching.js";
2
+ import { registerCypressEventListeners } from "./cypress.js";
3
+ import { injectFlushMessageHooks, registerMochaEventListeners } from "./mocha.js";
4
+ export var enableAllure = () => {
5
+ registerMochaEventListeners();
6
+ registerCypressEventListeners();
7
+ injectFlushMessageHooks();
8
+ enableScopeLevelAfterHookReporting();
9
+ };
10
+ export { enableReportingOfCypressScreenshots } from "./cypress.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["enableScopeLevelAfterHookReporting","registerCypressEventListeners","injectFlushMessageHooks","registerMochaEventListeners","enableAllure","enableReportingOfCypressScreenshots"],"sources":["../../../../src/browser/events/index.ts"],"sourcesContent":["import { enableScopeLevelAfterHookReporting } from \"../patching.js\";\nimport { registerCypressEventListeners } from \"./cypress.js\";\nimport { injectFlushMessageHooks, registerMochaEventListeners } from \"./mocha.js\";\n\nexport const enableAllure = () => {\n registerMochaEventListeners();\n registerCypressEventListeners();\n injectFlushMessageHooks();\n enableScopeLevelAfterHookReporting();\n};\n\nexport { enableReportingOfCypressScreenshots } from \"./cypress.js\";\n"],"mappings":"AAAA,SAASA,kCAAkC,QAAQ,gBAAgB;AACnE,SAASC,6BAA6B,QAAQ,cAAc;AAC5D,SAASC,uBAAuB,EAAEC,2BAA2B,QAAQ,YAAY;AAEjF,OAAO,IAAMC,YAAY,GAAGA,CAAA,KAAM;EAChCD,2BAA2B,CAAC,CAAC;EAC7BF,6BAA6B,CAAC,CAAC;EAC/BC,uBAAuB,CAAC,CAAC;EACzBF,kCAAkC,CAAC,CAAC;AACtC,CAAC;AAED,SAASK,mCAAmC,QAAQ,cAAc","ignoreList":[]}
@@ -0,0 +1,68 @@
1
+ import { completeHookErrorReporting, completeSpecIfNoAfterHookLeft, flushRuntimeMessages, reportTestPass as onPass, reportTestSkip as onPending, reportSuiteEnd as onSuiteEnd, reportTestEnd as onTestEnd, reportHookEnd, reportHookStart, reportRunStart, reportSuiteStart, reportTestOrHookFail, reportTestStart } from "../lifecycle.js";
2
+ import { initTestRuntime } from "../runtime.js";
3
+ import { applyTestPlan } from "../testplan.js";
4
+ import { isAllureHook, isRootAfterAllHook, isTestReported } from "../utils.js";
5
+ export var ALLURE_REPORT_SYSTEM_HOOK = "__allure_report_system_hook__";
6
+ export var registerMochaEventListeners = () => {
7
+ Cypress.mocha.getRunner().on("start", onStart).on("suite", onSuite).on("suite end", onSuiteEnd).on("hook", onHook).on("hook end", onHookEnd).on("test", onTest).on("pass", onPass).on("fail", onFail).on("pending", onPending).on("test end", onTestEnd);
8
+ };
9
+ export var injectFlushMessageHooks = () => {
10
+ afterEach(ALLURE_REPORT_SYSTEM_HOOK, flushRuntimeMessages);
11
+ after(ALLURE_REPORT_SYSTEM_HOOK, onAfterAll);
12
+ };
13
+ var onStart = () => {
14
+ initTestRuntime();
15
+ reportRunStart();
16
+ };
17
+ var onSuite = suite => {
18
+ if (suite.root) {
19
+ applyTestPlan(Cypress.spec, suite);
20
+ }
21
+ reportSuiteStart(suite);
22
+ };
23
+ var onHook = hook => {
24
+ if (isAllureHook(hook)) {
25
+ return;
26
+ }
27
+ reportHookStart(hook);
28
+ };
29
+ var onHookEnd = hook => {
30
+ if (isAllureHook(hook)) {
31
+ return;
32
+ }
33
+ reportHookEnd(hook);
34
+ };
35
+ var onTest = test => {
36
+ // Cypress emits an extra EVENT_TEST_BEGIN if the test is skipped.
37
+ // reportTestSkip does that already, so we need to filter the extra event out.
38
+ if (!isTestReported(test)) {
39
+ reportTestStart(test);
40
+ }
41
+ };
42
+ var onFail = (testOrHook, err) => {
43
+ var isHook = ("hookName" in testOrHook);
44
+ if (isHook && isRootAfterAllHook(testOrHook)) {
45
+ // Errors in spec-level 'after all' hooks are handled by Allure wrappers.
46
+ return;
47
+ }
48
+ var isAllureHookFailure = isHook && isAllureHook(testOrHook);
49
+ if (isAllureHookFailure) {
50
+ var _testOrHook$duration;
51
+ // Normally, Allure hooks are skipped from the report.
52
+ // In case of errors, it will be helpful to see them.
53
+ reportHookStart(testOrHook, Date.now() - ((_testOrHook$duration = testOrHook.duration) !== null && _testOrHook$duration !== void 0 ? _testOrHook$duration : 0));
54
+ }
55
+
56
+ // This will mark the fixture and the test (if any) as failed/broken.
57
+ reportTestOrHookFail(err);
58
+ if (isHook) {
59
+ // This will end the fixture and test (if any) and will report the remaining
60
+ // tests in the hook's suite (the ones that will be skipped by Cypress/Mocha).
61
+ completeHookErrorReporting(testOrHook, err);
62
+ }
63
+ };
64
+ var onAfterAll = function onAfterAll() {
65
+ flushRuntimeMessages();
66
+ completeSpecIfNoAfterHookLeft(this);
67
+ };
68
+ //# sourceMappingURL=mocha.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mocha.js","names":["completeHookErrorReporting","completeSpecIfNoAfterHookLeft","flushRuntimeMessages","reportTestPass","onPass","reportTestSkip","onPending","reportSuiteEnd","onSuiteEnd","reportTestEnd","onTestEnd","reportHookEnd","reportHookStart","reportRunStart","reportSuiteStart","reportTestOrHookFail","reportTestStart","initTestRuntime","applyTestPlan","isAllureHook","isRootAfterAllHook","isTestReported","ALLURE_REPORT_SYSTEM_HOOK","registerMochaEventListeners","Cypress","mocha","getRunner","on","onStart","onSuite","onHook","onHookEnd","onTest","onFail","injectFlushMessageHooks","afterEach","after","onAfterAll","suite","root","spec","hook","test","testOrHook","err","isHook","isAllureHookFailure","_testOrHook$duration","Date","now","duration"],"sources":["../../../../src/browser/events/mocha.ts"],"sourcesContent":["import type { CypressHook, CypressSuite, CypressTest } from \"../../types.js\";\nimport {\n completeHookErrorReporting,\n completeSpecIfNoAfterHookLeft,\n flushRuntimeMessages,\n reportTestPass as onPass,\n reportTestSkip as onPending,\n reportSuiteEnd as onSuiteEnd,\n reportTestEnd as onTestEnd,\n reportHookEnd,\n reportHookStart,\n reportRunStart,\n reportSuiteStart,\n reportTestOrHookFail,\n reportTestStart,\n} from \"../lifecycle.js\";\nimport { initTestRuntime } from \"../runtime.js\";\nimport { applyTestPlan } from \"../testplan.js\";\nimport { isAllureHook, isRootAfterAllHook, isTestReported } from \"../utils.js\";\n\nexport const ALLURE_REPORT_SYSTEM_HOOK = \"__allure_report_system_hook__\";\n\nexport const registerMochaEventListeners = () => {\n ((Cypress as any).mocha.getRunner() as Mocha.Runner)\n .on(\"start\", onStart)\n .on(\"suite\", onSuite)\n .on(\"suite end\", onSuiteEnd)\n .on(\"hook\", onHook)\n .on(\"hook end\", onHookEnd)\n .on(\"test\", onTest)\n .on(\"pass\", onPass)\n .on(\"fail\", onFail)\n .on(\"pending\", onPending)\n .on(\"test end\", onTestEnd);\n};\n\nexport const injectFlushMessageHooks = () => {\n afterEach(ALLURE_REPORT_SYSTEM_HOOK, flushRuntimeMessages);\n after(ALLURE_REPORT_SYSTEM_HOOK, onAfterAll);\n};\n\nconst onStart = () => {\n initTestRuntime();\n reportRunStart();\n};\n\nconst onSuite = (suite: CypressSuite) => {\n if (suite.root) {\n applyTestPlan(Cypress.spec, suite);\n }\n reportSuiteStart(suite);\n};\n\nconst onHook = (hook: CypressHook) => {\n if (isAllureHook(hook)) {\n return;\n }\n\n reportHookStart(hook);\n};\n\nconst onHookEnd = (hook: CypressHook) => {\n if (isAllureHook(hook)) {\n return;\n }\n\n reportHookEnd(hook);\n};\n\nconst onTest = (test: CypressTest) => {\n // Cypress emits an extra EVENT_TEST_BEGIN if the test is skipped.\n // reportTestSkip does that already, so we need to filter the extra event out.\n if (!isTestReported(test)) {\n reportTestStart(test);\n }\n};\n\nconst onFail = (testOrHook: CypressTest | CypressHook, err: Error) => {\n const isHook = \"hookName\" in testOrHook;\n if (isHook && isRootAfterAllHook(testOrHook)) {\n // Errors in spec-level 'after all' hooks are handled by Allure wrappers.\n return;\n }\n\n const isAllureHookFailure = isHook && isAllureHook(testOrHook);\n\n if (isAllureHookFailure) {\n // Normally, Allure hooks are skipped from the report.\n // In case of errors, it will be helpful to see them.\n reportHookStart(testOrHook, Date.now() - (testOrHook.duration ?? 0));\n }\n\n // This will mark the fixture and the test (if any) as failed/broken.\n reportTestOrHookFail(err);\n\n if (isHook) {\n // This will end the fixture and test (if any) and will report the remaining\n // tests in the hook's suite (the ones that will be skipped by Cypress/Mocha).\n completeHookErrorReporting(testOrHook, err);\n }\n};\n\nconst onAfterAll = function (this: Mocha.Context) {\n flushRuntimeMessages();\n completeSpecIfNoAfterHookLeft(this);\n};\n"],"mappings":"AACA,SACEA,0BAA0B,EAC1BC,6BAA6B,EAC7BC,oBAAoB,EACpBC,cAAc,IAAIC,MAAM,EACxBC,cAAc,IAAIC,SAAS,EAC3BC,cAAc,IAAIC,UAAU,EAC5BC,aAAa,IAAIC,SAAS,EAC1BC,aAAa,EAC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0 +1,11 @@
1
+ import { enableAllure, enableReportingOfCypressScreenshots } from "./events/index.js";
2
+ import { isAllureInitialized, setAllureInitialized } from "./state.js";
3
+ export var initializeAllure = () => {
4
+ if (isAllureInitialized()) {
5
+ return;
6
+ }
7
+ setAllureInitialized();
8
+ enableAllure();
9
+ enableReportingOfCypressScreenshots();
10
+ };
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["enableAllure","enableReportingOfCypressScreenshots","isAllureInitialized","setAllureInitialized","initializeAllure"],"sources":["../../../src/browser/index.ts"],"sourcesContent":["import { enableAllure, enableReportingOfCypressScreenshots } from \"./events/index.js\";\nimport { isAllureInitialized, setAllureInitialized } from \"./state.js\";\n\nexport const initializeAllure = () => {\n if (isAllureInitialized()) {\n return;\n }\n\n setAllureInitialized();\n\n enableAllure();\n enableReportingOfCypressScreenshots();\n};\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,mCAAmC,QAAQ,mBAAmB;AACrF,SAASC,mBAAmB,EAAEC,oBAAoB,QAAQ,YAAY;AAEtE,OAAO,IAAMC,gBAAgB,GAAGA,CAAA,KAAM;EACpC,IAAIF,mBAAmB,CAAC,CAAC,EAAE;IACzB;EACF;EAEAC,oBAAoB,CAAC,CAAC;EAEtBH,YAAY,CAAC,CAAC;EACdC,mCAAmC,CAAC,CAAC;AACvC,CAAC","ignoreList":[]}