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
package/README.md CHANGED
@@ -12,15 +12,21 @@
12
12
 
13
13
  ---
14
14
 
15
+ ## The documentation
16
+
17
+ The docs for Allure Cypress are available at [https://allurereport.org/docs/cypress/](https://allurereport.org/docs/cypress/).
18
+
15
19
  ## Installation
16
20
 
17
- Use your favorite Node.js package manager to install the required packages:
21
+ Install `allure-cypress` using a package manager of your choice. For example:
18
22
 
19
23
  ```shell
20
- npm add -D allure-cypress
24
+ npm install -D allure-cypress
21
25
  ```
22
26
 
23
- Add the following lines to your `cypress.config.js` file:
27
+ ## Usage
28
+
29
+ Call `allureCypress` to initialize the plugin from the `setupNodeEvents` function in `cypress.config.js`:
24
30
 
25
31
  ```javascript
26
32
  import { defineConfig } from "cypress";
@@ -44,13 +50,13 @@ Import `allure-cypress` in `cypress/support/e2e.js`:
44
50
  import "allure-cypress";
45
51
  ```
46
52
 
47
- Allure Cypress is ready to run now. When the test run completes, the result files
48
- will be collected in the `./allure-results` directory. If you want to use another
49
- location, provide it via the `resultsDir` configuration option ([see below](#allure-cypress-options)).
53
+ When the test run completes, the result files will be generated in the `./allure-results` directory.
54
+
55
+ You may select another location, or further customize the plugin's behavior with [the configuration options](https://allurereport.org/docs/cypress-configuration/).
50
56
 
51
57
  ### View the report
52
58
 
53
- > You need Allure Report to generate and open the report from result files. See the [installation instructions](https://allurereport.org/docs/install/) for more details.
59
+ > You need Allure Report to be installed on your machine to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) on how to get it.
54
60
 
55
61
  Generate Allure Report:
56
62
 
@@ -64,85 +70,56 @@ Open Allure Report:
64
70
  allure open ./allure-report
65
71
  ```
66
72
 
67
- ## The documentation
68
-
69
- Learn more about Allure Cypress from the official documentation at
70
- [https://allurereport.org/docs/cypress/](https://allurereport.org/docs/cypress/).
71
-
72
-
73
- ## Allure Cypress options
74
-
75
- Customize Allure Cypress by providing a configuration object as the third argument
76
- of `allureCypress`.
77
-
78
- The following options are supported:
73
+ ## Allure API
79
74
 
80
- | Option | Description | Default |
81
- |-------------------|----------------------------------------------------------------------------------------------------------------------|---------------------------------|
82
- | resultsDir | The path of the results folder. | `./allure-results` |
83
- | videoOnFailOnly | When video capturing is enabled, set this option to `true` to attach the video to failed specs only. | `false` |
84
- | links | Allure Runtime API link templates. | `undefined` |
85
- | stepsFromCommands | Options that affect how Allure creates steps from Cypress commands | See [below](#stepsfromcommands) |
86
- | environmentInfo | A set of key-value pairs to display in the Environment section of the report | `undefined` |
87
- | categories | An array of category definitions, each describing a [category of defects](https://allurereport.org/docs/categories/) | `undefined` |
75
+ Enhance the report by utilizing the Allure API:
88
76
 
89
- ### stepsFromCommands
77
+ ```js
78
+ import * as allure from "allure-js-commons";
90
79
 
91
- | Property | Description | Default |
92
- |-------------------|---------------------------------------------------------------------------------------------------------------------------------------------|---------|
93
- | maxArgumentLength | The maximum length of the parameter value created from Cypress command argument. The rest of the characters are replaces with `...`. | 128 |
94
- | maxArgumentDepth | The maximum depth of the Cypress command argument (an array or an object) that will be converted to the corresponding step parameter value. | 3 |
80
+ describe("signing in with a password", () => {
81
+ it("should sign in with a valid password", () => {
82
+ allure.description("The test checks if an active user with a valid password can sign in to the app.");
83
+ allure.epic("Signing in");
84
+ allure.feature("Sign in with a password");
85
+ allure.story("As an active user, I want to successfully sign in using a valid password");
86
+ allure.tags("signin", "ui", "positive");
87
+ allure.issue("https://github.com/allure-framework/allure-js/issues/900", "ISSUE-900");
88
+ allure.owner("eroshenkoam");
89
+ allure.parameter("browser", Cypress.browser.family);
95
90
 
91
+ allure.step("Prepare the user", () => {
92
+ return createAnActiveUserInDb();
93
+ }).then((user) => {
94
+ allure.step("Make a sign-in attempt", () => {
95
+ allure.step("Navigate to the sign-in page", () => {
96
+ // ...
97
+ });
96
98
 
97
- ### Example
99
+ allure.step("Fill the sign-in form", (stepContext) => {
100
+ stepContext.parameter("login", user.login);
101
+ stepContext.parameter("password", user.password, "masked");
98
102
 
99
- Here is an example of the Allure Cypress configuration:
103
+ // ...
104
+ });
100
105
 
101
- ```javascript
102
- import { defineConfig } from "cypress";
103
- import { allureCypress } from "allure-cypress/reporter";
106
+ allure.step("Submit the form", () => {
107
+ // ...
104
108
 
105
- export default defineConfig({
106
- e2e: {
107
- setupNodeEvents: (on, config) => {
108
- allureCypress(on, config, {
109
- resultsDir: "my-allure-results",
110
- videoOnFailOnly: true,
111
- links: {
112
- link: {
113
- urlTemplate: "https://github.com/allure-framework/allure-js/blob/main/%s",
114
- },
115
- issue: {
116
- urlTemplate: "https://github.com/allure-framework/allure-js/issues/%s",
117
- nameTemplate: "ISSUE-%s",
118
- },
119
- },
120
- stepsFromCommands: {
121
- maxArgumentLength: 64,
122
- maxArgumentDepth: 5,
123
- },
124
- environmentInfo: {
125
- OS: os.platform(),
126
- Architecture: os.arch(),
127
- NodeVersion: process.version,
128
- },
129
- categories: [
130
- {
131
- name: "Missing file errors",
132
- messageRegex: /^ENOENT: no such file or directory/,
133
- },
134
- ],
109
+ allure.attachment("cookies", JSON.stringify(cy.getCookies()), { contentType: "application/json" });
110
+ });
135
111
  });
112
+
136
113
 
137
- return config;
138
- },
139
- // other Cypress config properties ...
140
- },
114
+ allure.step("Assert the signed-in state", () => {
115
+ // ...
116
+ });
117
+ });
118
+ });
141
119
  });
142
120
  ```
143
121
 
144
- More details about Allure Cypress configuration are available at [https://allurereport.org/docs/cypress-configuration/](https://allurereport.org/docs/cypress-configuration/).
145
-
122
+ More details about the API are available at [https://allurereport.org/docs/cypress-reference/](https://allurereport.org/docs/cypress-reference/).
146
123
 
147
124
  ## Combining Allure with other Cypress plugins
148
125
 
@@ -223,8 +200,7 @@ Allure Cypress requires access to the following events:
223
200
 
224
201
  Otherwise, it may not work as expected.
225
202
 
226
- If you need to define your own handlers of those events, make sure to call the
227
- corresponding functions of the `allureCypress`s' return value:
203
+ If you need to define your own handlers of those events, make sure to call the corresponding functions of the `allureCypress`s' return value:
228
204
 
229
205
  ```javascript
230
206
  import { defineConfig } from "cypress";
@@ -255,7 +231,6 @@ export default defineConfig({
255
231
  ```
256
232
 
257
233
  If you want to combine Allure Cypress with other plugins, consider using
258
- [cypress-on-fix](https://github.com/bahmutov/cypress-on-fix). See the example for
259
- [the Cypress Cucumber preprocessor](#combining-allure-with-other-cypress-plugins) above.
234
+ [cypress-on-fix](https://github.com/bahmutov/cypress-on-fix). See the example for [the Cypress Cucumber preprocessor](#combining-allure-with-other-cypress-plugins) above.
260
235
 
261
236
  You may read more details and workarounds in issues [cypress-io/cypress#5240](https://github.com/cypress-io/cypress/issues/5240) and [cypress-io/cypress#22428](https://github.com/cypress-io/cypress/issues/22428).
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.stopCommandLogStep = exports.startCommandLogStep = exports.shouldCreateStepFromCommandLogEntry = exports.setupScreenshotAttachmentStep = void 0;
7
+ var _utils = require("../utils.js");
8
+ var _lifecycle = require("./lifecycle.js");
9
+ var _serialize = _interopRequireDefault(require("./serialize.js"));
10
+ var _state = require("./state.js");
11
+ var _steps = require("./steps.js");
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ var shouldCreateStepFromCommandLogEntry = entry => {
14
+ var {
15
+ event,
16
+ instrument
17
+ } = entry.attributes;
18
+ if (instrument !== "command") {
19
+ // We are interested in the "TEST BODY" panel only for now.
20
+ // Other instruments are logged in separate panels.
21
+ return false;
22
+ }
23
+ if (event) {
24
+ // Events are tricky to report as they may span across commands and even leave the test's scope.
25
+ // We ignore them for now.
26
+ return false;
27
+ }
28
+ if (isApiStepErrorLogEntry(entry)) {
29
+ // Cypress don't create a log message for 'cy.then' except when it throws an error.
30
+ // This is in particularly happens when the function passed to 'allure.step' throws. In such a case however,
31
+ // creating an extra step from the log entry is redundant because the error is already included in the report as
32
+ // a part of the step.
33
+ return false;
34
+ }
35
+ return true;
36
+ };
37
+
38
+ /**
39
+ * Checks if the current step represents a cy.screenshot command log entry. If this is the case, associates the name
40
+ * of the screenshot with the step. Later, that will allow converting the step with the attachment into the attachment
41
+ * step.
42
+ */
43
+ exports.shouldCreateStepFromCommandLogEntry = shouldCreateStepFromCommandLogEntry;
44
+ var setupScreenshotAttachmentStep = (originalName, name) => {
45
+ var step = (0, _state.getCurrentStep)();
46
+ if (step && (0, _steps.isLogStep)(step)) {
47
+ var {
48
+ name: commandName,
49
+ props: {
50
+ name: nameFromProps
51
+ }
52
+ } = step.log.attributes.consoleProps();
53
+ if (commandName === "screenshot" && nameFromProps === originalName) {
54
+ step.attachmentName = name;
55
+ }
56
+ }
57
+ };
58
+ exports.setupScreenshotAttachmentStep = setupScreenshotAttachmentStep;
59
+ var startCommandLogStep = entry => {
60
+ var currentLogEntry = getCurrentLogEntry();
61
+ if (typeof currentLogEntry !== "undefined" && shouldStopCurrentLogStep(currentLogEntry.log, entry)) {
62
+ stopCommandLogStep(currentLogEntry.log.attributes.id);
63
+ }
64
+ pushLogEntry(entry);
65
+ (0, _lifecycle.reportStepStart)(entry.attributes.id, getCommandLogStepName(entry));
66
+ scheduleCommandLogStepStop(entry);
67
+ };
68
+ exports.startCommandLogStep = startCommandLogStep;
69
+ var stopCommandLogStep = entryId => (0, _steps.findAndStopStepWithSubsteps)(_ref => {
70
+ var {
71
+ id
72
+ } = _ref;
73
+ return id === entryId;
74
+ });
75
+ exports.stopCommandLogStep = stopCommandLogStep;
76
+ var pushLogEntry = entry => {
77
+ var id = entry.attributes.id;
78
+ var stepDescriptor = {
79
+ id,
80
+ type: "log",
81
+ log: entry
82
+ };
83
+ (0, _state.pushStep)(stepDescriptor);
84
+
85
+ // Some properties of some Command Log entries are undefined at the time the entry is stopped. An example is the
86
+ // Yielded property of some queries. We defer converting them to Allure step parameters until the test/hook ends.
87
+ (0, _state.setupStepFinalization)(stepDescriptor, data => {
88
+ data.parameters = getCommandLogStepParameters(entry);
89
+ if (stepDescriptor.attachmentName) {
90
+ // Rename the step to match the attachment name. Once the names are the same, Allure will render the
91
+ // attachment in the place of the step.
92
+ data.name = stepDescriptor.attachmentName;
93
+ }
94
+ });
95
+ };
96
+ var scheduleCommandLogStepStop = entry => {
97
+ var {
98
+ groupStart,
99
+ end,
100
+ id
101
+ } = entry.attributes;
102
+ if (end) {
103
+ // Some entries are already completed (this is similar to the idea behind allure.logStep).
104
+ // Cypress won't call entry.end() in such a case, so we need to stop such a step now.
105
+ // Example: cy.log
106
+ stopCommandLogStep(id);
107
+ } else if (groupStart) {
108
+ // A logging group must be stopped be the user via the Cypress.Log.endGroup() call.
109
+ // If the call is missing, the corresponding step will be stopped either at the test's (the hook's) end.
110
+ var originalEndGroup = entry.endGroup;
111
+ entry.endGroup = function () {
112
+ stopCommandLogStep(id);
113
+ return originalEndGroup.call(this);
114
+ };
115
+ } else {
116
+ // Regular log entries are finalized by Cypress via the Cypress.Log.end() call. We're hooking into this function
117
+ // to complete the step at the same time.
118
+ // eslint-disable-next-line @typescript-eslint/unbound-method
119
+ var originalEnd = entry.end;
120
+ entry.end = function () {
121
+ stopCommandLogStep(id);
122
+ return originalEnd.call(this);
123
+ };
124
+ }
125
+ };
126
+ var isApiStepErrorLogEntry = _ref2 => {
127
+ var {
128
+ attributes: {
129
+ name,
130
+ consoleProps
131
+ }
132
+ } = _ref2;
133
+ return name === "then" && Object.is(consoleProps().props["Applied To"], _steps.ALLURE_STEP_CMD_SUBJECT);
134
+ };
135
+ var getCommandLogStepName = entry => {
136
+ var _ref3, _ref4, _maybeGetAssertionLog;
137
+ var {
138
+ name,
139
+ message,
140
+ displayName
141
+ } = entry.attributes;
142
+ var resolvedName = (displayName !== null && displayName !== void 0 ? displayName : name).trim();
143
+ 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();
144
+ var stepName = [resolvedName, resolvedMessage].filter(Boolean).join(" ");
145
+ return stepName;
146
+ };
147
+ var getCommandLogStepParameters = entry => getLogProps(entry).map(_ref5 => {
148
+ var [k, v] = _ref5;
149
+ return {
150
+ name: k.toString(),
151
+ value: (0, _serialize.default)(v)
152
+ };
153
+ }).filter(getPropValueSetFilter(entry));
154
+ var WELL_KNOWN_CUCUMBER_LOG_NAMES = ["Given", "When", "Then", "And"];
155
+ var maybeGetCucumberLogMessage = entry => {
156
+ var {
157
+ attributes: {
158
+ name,
159
+ message
160
+ }
161
+ } = entry;
162
+ if (WELL_KNOWN_CUCUMBER_LOG_NAMES.includes(name.trim()) && message.startsWith("**") && message.endsWith("**")) {
163
+ return message.substring(2, message.length - 2);
164
+ }
165
+ };
166
+ var getLogProps = entry => {
167
+ var {
168
+ attributes: {
169
+ consoleProps
170
+ }
171
+ } = entry;
172
+ var isAssertionWithMessage = !!maybeGetAssertionLogMessage(entry);
173
+
174
+ // For assertion logs, we interpolate the 'Message' property, which contains unformatted assertion description,
175
+ // directly into the step's name.
176
+ // No need to keep the exact same information in the step's parameters.
177
+ return Object.entries(consoleProps().props).filter(_ref6 => {
178
+ var [k, v] = _ref6;
179
+ return (0, _utils.isDefined)(v) && !(isAssertionWithMessage && k === "Message");
180
+ });
181
+ };
182
+ var maybeGetAssertionLogMessage = entry => {
183
+ if (isAssertLog(entry)) {
184
+ var message = entry.attributes.consoleProps().props.Message;
185
+ if (message && typeof message === "string") {
186
+ return message;
187
+ }
188
+ }
189
+ };
190
+ var isAssertLog = _ref7 => {
191
+ var {
192
+ attributes: {
193
+ name
194
+ }
195
+ } = _ref7;
196
+ return name === "assert";
197
+ };
198
+ var getCurrentLogEntry = () => (0, _state.getStepStack)().findLast(_steps.isLogStep);
199
+ var shouldStopCurrentLogStep = (currentLogEntry, newLogEntry) => {
200
+ var {
201
+ groupStart: currentEntryIsGroup,
202
+ type: currentEntryType
203
+ } = currentLogEntry.attributes;
204
+ var {
205
+ type: newEntryType
206
+ } = newLogEntry.attributes;
207
+ return !currentEntryIsGroup && (currentEntryType === "child" || newEntryType !== "child");
208
+ };
209
+ var getPropValueSetFilter = entry => entry.attributes.name === "wrap" ? () => true : _ref8 => {
210
+ var {
211
+ name,
212
+ value
213
+ } = _ref8;
214
+ return name !== "Yielded" || value !== "{}";
215
+ };
216
+ //# sourceMappingURL=commandLog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandLog.js","names":["_utils","require","_lifecycle","_serialize","_interopRequireDefault","_state","_steps","e","__esModule","default","shouldCreateStepFromCommandLogEntry","entry","event","instrument","attributes","isApiStepErrorLogEntry","exports","setupScreenshotAttachmentStep","originalName","name","step","getCurrentStep","isLogStep","commandName","props","nameFromProps","log","consoleProps","attachmentName","startCommandLogStep","currentLogEntry","getCurrentLogEntry","shouldStopCurrentLogStep","stopCommandLogStep","id","pushLogEntry","reportStepStart","getCommandLogStepName","scheduleCommandLogStepStop","entryId","findAndStopStepWithSubsteps","_ref","stepDescriptor","type","pushStep","setupStepFinalization","data","parameters","getCommandLogStepParameters","groupStart","end","originalEndGroup","endGroup","call","originalEnd","_ref2","Object","is","ALLURE_STEP_CMD_SUBJECT","_ref3","_ref4","_maybeGetAssertionLog","message","displayName","resolvedName","trim","resolvedMessage","maybeGetAssertionLogMessage","maybeGetCucumberLogMessage","renderProps","stepName","filter","Boolean","join","getLogProps","map","_ref5","k","v","toString","value","serializePropValue","getPropValueSetFilter","WELL_KNOWN_CUCUMBER_LOG_NAMES","includes","startsWith","endsWith","substring","length","isAssertionWithMessage","entries","_ref6","isDefined","isAssertLog","Message","_ref7","getStepStack","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,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAA6F,SAAAG,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEtF,IAAMG,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;;AAED;AACA;AACA;AACA;AACA;AAJAK,OAAA,CAAAN,mCAAA,GAAAA,mCAAA;AAKO,IAAMO,6BAA6B,GAAGA,CAACC,YAAgC,EAAEC,I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OA,OAAO,KAAK,QAAQ,EAAE;MAC1C,OAAOA,OAAO;IAChB;EACF;AACF,CAAC;AAED,IAAM+B,WAAW,GAAGE,KAAA;EAAA,IAAC;IAAEjF,UAAU,EAAE;MAAEK;IAAK;EAAmB,CAAC,GAAA4E,KAAA;EAAA,OAAK5E,IAAI,KAAK,QAAQ;AAAA;AAEpF,IAAMY,kBAAkB,GAAGA,CAAA,KAAM,IAAAiE,mBAAY,EAAC,CAAC,CAACC,QAAQ,CAAC3E,gBAAS,CAAC;AAEnE,IAAMU,wBAAwB,GAAGA,CAACF,eAAgC,EAAEoE,WAA4B,KAAK;EACnG,IAAM;IAAEjD,UAAU,EAAEkD,mBAAmB;IAAExD,IAAI,EAAEyD;EAAiB,CAAC,GAAGtE,eAAe,CAAChB,UAAU;EAC9F,IAAM;IAAE6B,IAAI,EAAE0D;EAAa,CAAC,GAAGH,WAAW,CAACpF,UAAU;EAErD,OAAO,CAACqF,mBAAmB,KAAKC,gBAAgB,KAAK,OAAO,IAAIC,YAAY,KAAK,OAAO,CAAC;AAC3F,CAAC;AAED,IAAMnB,qBAAqB,GAAIvE,KAAsB,IACnDA,KAAK,CAACG,UAAU,CAACK,IAAI,KAAK,MAAM,GAAG,MAAM,IAAI,GAAGmF,KAAA;EAAA,IAAC;IAAEnF,IAAI;IAAE6D;EAAiB,CAAC,GAAAsB,KAAA;EAAA,OAAKnF,IAAI,KAAK,SAAS,IAAI6D,KAAK,KAAK,IAAI;AAAA","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.registerCypressEventListeners = exports.enableReportingOfCypressScreenshots = void 0;
7
+ var _commandLog = require("../commandLog.js");
8
+ var _lifecycle = require("../lifecycle.js");
9
+ var _steps = require("../steps.js");
10
+ var _utils = require("../utils.js");
11
+ var registerCypressEventListeners = () => Cypress.on("fail", onFail).on("log:added", onLogAdded);
12
+ exports.registerCypressEventListeners = registerCypressEventListeners;
13
+ var enableReportingOfCypressScreenshots = () => Cypress.Screenshot.defaults({
14
+ onAfterScreenshot
15
+ });
16
+ exports.enableReportingOfCypressScreenshots = enableReportingOfCypressScreenshots;
17
+ var onAfterScreenshot = function onAfterScreenshot() {
18
+ for (var _len = arguments.length, _ref = new Array(_len), _key = 0; _key < _len; _key++) {
19
+ _ref[_key] = arguments[_key];
20
+ }
21
+ var [, {
22
+ name: originalName,
23
+ path
24
+ }] = _ref;
25
+ var name = originalName !== null && originalName !== void 0 ? originalName : (0, _utils.getFileNameFromPath)(path);
26
+ (0, _lifecycle.reportScreenshot)(path, name);
27
+ (0, _commandLog.setupScreenshotAttachmentStep)(originalName, name);
28
+ };
29
+ var onLogAdded = (_, entry) => {
30
+ if ((0, _commandLog.shouldCreateStepFromCommandLogEntry)(entry)) {
31
+ (0, _commandLog.startCommandLogStep)(entry);
32
+ }
33
+ };
34
+ var onFail = error => {
35
+ (0, _steps.reportStepError)(error);
36
+
37
+ // If there are more "fail" handlers yet to run, it's not our responsibility to throw.
38
+ // Otherwise, we won't give them any chance to do their job (EventEmitter stops executing handlers as soon
39
+ // as one of them throws - that is also true for eventemitter2, which is used by the browser-side of Cypress).
40
+ if (noSubsequentFailListeners()) {
41
+ throw error;
42
+ }
43
+ };
44
+ var noSubsequentFailListeners = () => Object.is(Cypress.listeners("fail").at(-1), onFail);
45
+ //# sourceMappingURL=cypress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cypress.js","names":["_commandLog","require","_lifecycle","_steps","_utils","registerCypressEventListeners","Cypress","on","onFail","onLogAdded","exports","enableReportingOfCypressScreenshots","Screenshot","defaults","onAfterScreenshot","_len","arguments","length","_ref","Array","_key","name","originalName","path","getFileNameFromPath","reportScreenshot","setupScreenshotAttachmentStep","_","entry","shouldCreateStepFromCommandLogEntry","startCommandLogStep","error","reportStepError","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,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,IAAMI,6BAA6B,GAAGA,CAAA,KAAMC,OAAO,CAACC,EAAE,CAAC,MAAM,EAAEC,MAAM,CAAC,CAACD,EAAE,CAAC,WAAW,EAAEE,UAAU,CAAC;AAACC,OAAA,CAAAL,6BAAA,GAAAA,6BAAA;AAEnG,IAAMM,mCAAmC,GAAGA,CAAA,KAAML,OAAO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, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.enableAllure = void 0;
7
+ Object.defineProperty(exports, "enableReportingOfCypressScreenshots", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _cypress.enableReportingOfCypressScreenshots;
11
+ }
12
+ });
13
+ var _patching = require("../patching.js");
14
+ var _cypress = require("./cypress.js");
15
+ var _mocha = require("./mocha.js");
16
+ var enableAllure = () => {
17
+ (0, _mocha.registerMochaEventListeners)();
18
+ (0, _cypress.registerCypressEventListeners)();
19
+ (0, _mocha.injectFlushMessageHooks)();
20
+ (0, _patching.enableScopeLevelAfterHookReporting)();
21
+ };
22
+ exports.enableAllure = enableAllure;
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_patching","require","_cypress","_mocha","enableAllure","registerMochaEventListeners","registerCypressEventListeners","injectFlushMessageHooks","enableScopeLevelAfterHookReporting","exports"],"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,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,IAAMG,YAAY,GAAGA,CAAA,KAAM;EAChC,IAAAC,kCAA2B,EAAC,CAAC;EAC7B,IAAAC,sCAA6B,EAAC,CAAC;EAC/B,IAAAC,8BAAuB,EAAC,CAAC;EACzB,IAAAC,4CAAkC,EAAC,CAAC;AACtC,CAAC;AAACC,OAAA,CAAAL,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.registerMochaEventListeners = exports.injectFlushMessageHooks = exports.ALLURE_REPORT_SYSTEM_HOOK = void 0;
7
+ var _lifecycle = require("../lifecycle.js");
8
+ var _runtime = require("../runtime.js");
9
+ var _testplan = require("../testplan.js");
10
+ var _utils = require("../utils.js");
11
+ var ALLURE_REPORT_SYSTEM_HOOK = exports.ALLURE_REPORT_SYSTEM_HOOK = "__allure_report_system_hook__";
12
+ var registerMochaEventListeners = () => {
13
+ Cypress.mocha.getRunner().on("start", onStart).on("suite", onSuite).on("suite end", _lifecycle.reportSuiteEnd).on("hook", onHook).on("hook end", onHookEnd).on("test", onTest).on("pass", _lifecycle.reportTestPass).on("fail", onFail).on("pending", _lifecycle.reportTestSkip).on("test end", _lifecycle.reportTestEnd);
14
+ };
15
+ exports.registerMochaEventListeners = registerMochaEventListeners;
16
+ var injectFlushMessageHooks = () => {
17
+ afterEach(ALLURE_REPORT_SYSTEM_HOOK, _lifecycle.flushRuntimeMessages);
18
+ after(ALLURE_REPORT_SYSTEM_HOOK, onAfterAll);
19
+ };
20
+ exports.injectFlushMessageHooks = injectFlushMessageHooks;
21
+ var onStart = () => {
22
+ (0, _runtime.initTestRuntime)();
23
+ (0, _lifecycle.reportRunStart)();
24
+ };
25
+ var onSuite = suite => {
26
+ if (suite.root) {
27
+ (0, _testplan.applyTestPlan)(Cypress.spec, suite);
28
+ }
29
+ (0, _lifecycle.reportSuiteStart)(suite);
30
+ };
31
+ var onHook = hook => {
32
+ if ((0, _utils.isAllureHook)(hook)) {
33
+ return;
34
+ }
35
+ (0, _lifecycle.reportHookStart)(hook);
36
+ };
37
+ var onHookEnd = hook => {
38
+ if ((0, _utils.isAllureHook)(hook)) {
39
+ return;
40
+ }
41
+ (0, _lifecycle.reportHookEnd)(hook);
42
+ };
43
+ var onTest = test => {
44
+ // Cypress emits an extra EVENT_TEST_BEGIN if the test is skipped.
45
+ // reportTestSkip does that already, so we need to filter the extra event out.
46
+ if (!(0, _utils.isTestReported)(test)) {
47
+ (0, _lifecycle.reportTestStart)(test);
48
+ }
49
+ };
50
+ var onFail = (testOrHook, err) => {
51
+ var isHook = ("hookName" in testOrHook);
52
+ if (isHook && (0, _utils.isRootAfterAllHook)(testOrHook)) {
53
+ // Errors in spec-level 'after all' hooks are handled by Allure wrappers.
54
+ return;
55
+ }
56
+ var isAllureHookFailure = isHook && (0, _utils.isAllureHook)(testOrHook);
57
+ if (isAllureHookFailure) {
58
+ var _testOrHook$duration;
59
+ // Normally, Allure hooks are skipped from the report.
60
+ // In case of errors, it will be helpful to see them.
61
+ (0, _lifecycle.reportHookStart)(testOrHook, Date.now() - ((_testOrHook$duration = testOrHook.duration) !== null && _testOrHook$duration !== void 0 ? _testOrHook$duration : 0));
62
+ }
63
+
64
+ // This will mark the fixture and the test (if any) as failed/broken.
65
+ (0, _lifecycle.reportTestOrHookFail)(err);
66
+ if (isHook) {
67
+ // This will end the fixture and test (if any) and will report the remaining
68
+ // tests in the hook's suite (the ones that will be skipped by Cypress/Mocha).
69
+ (0, _lifecycle.completeHookErrorReporting)(testOrHook, err);
70
+ }
71
+ };
72
+ var onAfterAll = function onAfterAll() {
73
+ (0, _lifecycle.flushRuntimeMessages)();
74
+ (0, _lifecycle.completeSpecIfNoAfterHookLeft)(this);
75
+ };
76
+ //# sourceMappingURL=mocha.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mocha.js","names":["_lifecycle","require","_runtime","_testplan","_utils","ALLURE_REPORT_SYSTEM_HOOK","exports","registerMochaEventListeners","Cypress","mocha","getRunner","on","onStart","onSuite","onSuiteEnd","onHook","onHookEnd","onTest","onPass","onFail","onPending","onTestEnd","injectFlushMessageHooks","afterEach","flushRuntimeMessages","after","onAfterAll","initTestRuntime","reportRunStart","suite","root","applyTestPlan","spec","reportSuiteStart","hook","isAllureHook","reportHookStart","reportHookEnd","test","isTestReported","reportTestStart","testOrHook","err","isHook","isRootAfterAllHook","isAllureHookFailure","_testOrHook$duration","Date","now","duration","reportTestOrHookFail","completeHookErrorReporting","completeSpecIfNoAfterHookLeft"],"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,IAAAA,UAAA,GAAAC,OAAA;AAeA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,IAAMI,yBAAyB,GAAAC,OAAA,CAAAD,yBAAA,GAAG,+BAA+B;AAEjE,IAAME,2BAA2B,GAAGA,CAAA,KAAM;EAC7CC,OAAO,CAASC,KAAK,CAACC,SAAS,CAAC,CAAC,CAChCC,EAAE,CAAC,OAAO,EAAEC,OAAO,CAAC,CACpBD,EAAE,CAAC,OAAO,EAAEE,OAAO,CAAC,CACpBF,EAAE,CAAC,WAAW,EAAEG,yBAAU,CAAC,CAC3BH,EAAE,CAAC,MAAM,EAAEI,MAAM,CAAC,CAClBJ,EAAE,CAAC,UAAU,EAAEK,SAAS,CAAC,CACzBL,EAAE,CAAC,MAAM,E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AC;AAED,IAAMnB,MAAM,GAAGA,CAACsB,UAAqC,EAAEC,GAAU,KAAK;EACpE,IAAMC,MAAM,IAAG,UAAU,IAAIF,UAAU;EACvC,IAAIE,MAAM,IAAI,IAAAC,yBAAkB,EAACH,UAAU,CAAC,EAAE;IAC5C;IACA;EACF;EAEA,IAAMI,mBAAmB,GAAGF,MAAM,IAAI,IAAAR,mBAAY,EAACM,UAAU,CAAC;EAE9D,IAAII,mBAAmB,EAAE;IAAA,IAAAC,oBAAA;IACvB;IACA;IACA,IAAAV,0BAAe,EAACK,UAAU,EAAEM,IAAI,CAACC,GAAG,CAAC,CAAC,KAAAF,oBAAA,GAAIL,UAAU,CAACQ,QAAQ,cAAAH,oBAAA,cAAAA,oBAAA,GAAI,CAAC,CAAC,CAAC;EACtE;;EAEA;EACA,IAAAI,+BAAoB,EAACR,GAAG,CAAC;EAEzB,IAAIC,MAAM,EAAE;IACV;IACA;IACA,IAAAQ,qCAA0B,EAACV,UAAU,EAAEC,GAAG,CAAC;EAC7C;AACF,CAAC;AAED,IAAMhB,UAAU,GAAG,SAAbA,UAAUA,CAAA,EAAkC;EAChD,IAAAF,+BAAoB,EAAC,CAAC;EACtB,IAAA4B,wCAA6B,EAAC,IAAI,CAAC;AACrC,CAAC","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.initializeAllure = void 0;
7
+ var _index = require("./events/index.js");
8
+ var _state = require("./state.js");
9
+ var initializeAllure = () => {
10
+ if ((0, _state.isAllureInitialized)()) {
11
+ return;
12
+ }
13
+ (0, _state.setAllureInitialized)();
14
+ (0, _index.enableAllure)();
15
+ (0, _index.enableReportingOfCypressScreenshots)();
16
+ };
17
+ exports.initializeAllure = initializeAllure;
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_index","require","_state","initializeAllure","isAllureInitialized","setAllureInitialized","enableAllure","enableReportingOfCypressScreenshots","exports"],"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,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,IAAME,gBAAgB,GAAGA,CAAA,KAAM;EACpC,IAAI,IAAAC,0BAAmB,EAAC,CAAC,EAAE;IACzB;EACF;EAEA,IAAAC,2BAAoB,EAAC,CAAC;EAEtB,IAAAC,mBAAY,EAAC,CAAC;EACd,IAAAC,0CAAmC,EAAC,CAAC;AACvC,CAAC;AAACC,OAAA,CAAAL,gBAAA,GAAAA,gBAAA","ignoreList":[]}