allure-cypress 3.0.0-beta.1 → 3.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,177 +14,195 @@
14
14
 
15
15
  ## Installation
16
16
 
17
- Use your favorite node package manager to install the required packages:
17
+ Use your favorite Node.js package manager to install the required packages:
18
18
 
19
19
  ```shell
20
20
  npm add -D allure-cypress
21
21
  ```
22
22
 
23
- Add the following lines to your `cypress.config.js` file to setup the reporter:
23
+ Add the following lines to your `cypress.config.js` file:
24
24
 
25
- ```diff
26
- const { allureCypress } = require("allure-cypress/reporter");
25
+ ```javascript
26
+ import { defineConfig } from "cypress";
27
+ import { allureCypress } from "allure-cypress/reporter";
27
28
 
28
- module.exports = {
29
- // ...
29
+ export default defineConfig({
30
30
  e2e: {
31
- + setupNodeEvents: (on, config) => {
32
- + allureCypress(on, {
33
- + resultsDir: "./allure-results",
34
- + });
35
- +
36
- + return config;
37
- + },
31
+ setupNodeEvents: (on, config) => {
32
+ allureCypress(on, config);
33
+
34
+ return config;
35
+ },
36
+ // ...
38
37
  },
39
- };
38
+ });
40
39
  ```
41
40
 
42
- Don't forget to add the Allure Cypress commands to your `cypress/support/e2e.js` file to finish
43
- the installation:
41
+ Import `allure-cypress` in `cypress/support/e2e.js`:
44
42
 
45
- ```diff
46
- + import "allure-cypress";
43
+ ```javascript
44
+ import "allure-cypress";
47
45
  ```
48
46
 
49
- ## Use Allure runtime Api
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)).
50
50
 
51
- The plugin provides custom commands which allow to add additional info inside your tests:
51
+ ### View the report
52
52
 
53
- ```javascript
54
- import { epic, attachment, parameter } from "allure-js-commons";
55
-
56
- it("my test", () => {
57
- attachment("Attachment name", "Hello world!", "text/plain");
58
- epic("my_epic");
59
- parameter("parameter_name", "parameter_value", {
60
- mode: "hidden",
61
- excluded: false,
62
- });
63
- });
64
- ```
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.
54
+
55
+ Generate Allure Report:
65
56
 
66
- ## Links usage
57
+ ```bash
58
+ allure generate ./allure-results -o ./allure-report
59
+ ```
67
60
 
68
- ```js
69
- import { link, issue, tms } from "allure-js-commons";
61
+ Open Allure Report:
70
62
 
71
- it("basic test", () => {
72
- link("link_type", "https://allurereport.org", "Allure Report");
73
- issue("Issue Name", "https://github.com/allure-framework/allure-js/issues/352");
74
- tms("Task Name", "https://github.com/allure-framework/allure-js/tasks/352");
75
- });
63
+ ```bash
64
+ allure open ./allure-report
76
65
  ```
77
66
 
78
- You can also configure links formatters to make usage much more convenient. `%s`
79
- in `urlTemplate` parameter will be replaced by given value.
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/).
80
71
 
81
- ```diff
82
- const { allureCypress } = require("allure-cypress/reporter");
83
72
 
84
- module.exports = {
85
- // ...
73
+ ## Allure Cypress options
74
+ | Option | Description | Default |
75
+ |-----------------|----------------------------------------------------------------------------------------------------------------------|--------------------|
76
+ | resultsDir | The path of the results folder. | `./allure-results` |
77
+ | videoOnFailOnly | When video capturing is enabled, set this option to `true` to attach the video to failed specs only. | `undefined` |
78
+ | links | Allure Runtime API link templates. | `undefined` |
79
+ | environmentInfo | A set of key-value pairs to display in the Environment section of the report | `undefined` |
80
+ | categories | An array of category definitions, each describing a [category of defects](https://allurereport.org/docs/categories/) | `undefined` |
81
+
82
+ Here is an example of the Allure Cypress configuration:
83
+
84
+ ```javascript
85
+ import { defineConfig } from "cypress";
86
+ import { allureCypress } from "allure-cypress/reporter";
87
+
88
+ export default defineConfig({
86
89
  e2e: {
87
90
  setupNodeEvents: (on, config) => {
88
- const reporter = allureCypress(on, {
89
- + links: [
90
- + {
91
- + type: "issue",
92
- + urlTemplate: "https://example.org/issues/%s",
93
- + nameTemplate: "Issue: %s",
94
- + },
95
- + {
96
- + type: "tms",
97
- + urlTemplate: "https://example.org/tasks/%s"
98
- + },
99
- + {
100
- + type: "custom",
101
- + urlTemplate: "https://example.org/custom/%s"
102
- + },
103
- + ],
104
- + });
105
-
106
- on("after:spec", (spec, result) => {
107
- reporter.endSpec(spec, result);
91
+ allureCypress(on, config, {
92
+ resultsDir: "my-allure-results",
93
+ videoOnFailOnly: true,
94
+ links: {
95
+ link: {
96
+ urlTemplate: "https://github.com/allure-framework/allure-js/blob/main/%s",
97
+ },
98
+ issue: {
99
+ urlTemplate: "https://github.com/allure-framework/allure-js/issues/%s",
100
+ nameTemplate: "ISSUE-%s",
101
+ },
102
+ },
103
+ environmentInfo: {
104
+ OS: os.platform(),
105
+ Architecture: os.arch(),
106
+ NodeVersion: process.version,
107
+ },
108
+ categories: [
109
+ {
110
+ name: "Missing file errors",
111
+ messageRegex: /^ENOENT: no such file or directory/,
112
+ },
113
+ ],
108
114
  });
109
115
 
110
116
  return config;
111
117
  },
118
+ // other Cypress config properties ...
112
119
  },
113
- };
120
+ });
114
121
  ```
115
122
 
116
- Then you can assign link using shorter notation:
123
+ More details about Allure Cypress configuration are available at [https://allurereport.org/docs/cypress-configuration/](https://allurereport.org/docs/cypress-configuration/).
117
124
 
118
- ```js
119
- import { link, issue, tms } from "allure-js-commons";
120
125
 
121
- it("basic test", () => {
122
- issue("351");
123
- issue("352", "Issue Name");
124
- tms("351");
125
- tms("352", "Task Name");
126
- link("custom", "352");
127
- link("custom", "352", "Link name");
128
- });
129
- ```
126
+ ## Combining Allure with other Cypress plugins
127
+
128
+ Use [cypress-on-fix](https://github.com/bahmutov/cypress-on-fix) to enable Allure
129
+ with other Cypress plugins. See more info [here](#setupnodeevents-limitations).
130
130
 
131
- ## Steps usage
131
+ In the next example, Allure Cypress is enabled together with [@badeball/cypress-cucumber-preprocessor](https://github.com/badeball/cypress-cucumber-preprocessor):
132
132
 
133
- The integration supports Allure steps, use them in following way:
133
+ ```javascript
134
+ import { defineConfig } from "cypress";
135
+ import { allureCypress } from "allure-cypress/reporter";
136
+ import createBundler from "@bahmutov/cypress-esbuild-preprocessor";
137
+ import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor";
138
+ import { createEsbuildPlugin } from "@badeball/cypress-cucumber-preprocessor/esbuild";
139
+ import cypressOnFix from "cypress-on-fix";
140
+
141
+ export default defineConfig({
142
+ e2e: {
143
+ setupNodeEvents = async (on, config) => {
144
+ on = cypressOnFix(on);
145
+ await addCucumberPreprocessorPlugin(on, config);
134
146
 
135
- ```js
136
- import { step } from "allure-js-commons";
147
+ on("file:preprocessor", createBundler({
148
+ plugins: [createEsbuildPlugin(config)],
149
+ }));
137
150
 
138
- it("my test", () => {
139
- step("foo", () => {
140
- step("bar", () => {
141
- step("baz", () => {
142
- cy.log("my cypress commands");
143
- });
144
- });
145
- });
151
+ allureCypress(on, config);
152
+
153
+ return config;
154
+ },
155
+ // ...
156
+ },
146
157
  });
147
158
  ```
148
159
 
149
- ## Passing metadata from test title
160
+ ## Known limitations
150
161
 
151
- You also can pass allure metadata from test title.
152
- This is useful when you need to set allureId for the tests with failing before hooks. Just add `@allure.id={idValue}` for the allureId or `@allure.label.{labelName}={labelValue}` for other types of labels.
162
+ ### `setupNodeEvents` limitations
153
163
 
154
- ```ts
155
- it("test with allureId @allure.id=256", () => {});
156
- it("tst with severity @allure.label.severity=critical", () => {});
157
- it("test with epic @allure.label.epic=login", () => {});
158
- it("test with strangeLabel @allure.label.strangeLabel=strangeValue", () => {});
159
- ```
164
+ Cypress can't compose multiple Node events, which are set in `setupNodeEvents`.
160
165
 
161
- > **Warning**
162
- > Note that changing title can cause creating new testcases in history.
163
- > To fix this please add `@allure.id={yourTestCaseId}` to the test name if you passing allure metadata from test title
166
+ Allure Cypress requires access to the following events:
164
167
 
165
- ## Using custom `after:spec` hook
168
+ - `after:spec`
169
+ - `after:run`
166
170
 
167
- If you want to use your own `after:spec` hook and keep the Allure reporter working, you should use `AllureCypress` class instead:
171
+ Otherwise, it may not work as expected.
168
172
 
169
- ```diff
170
- const { AllureCypress } = require("allure-cypress/reporter");
173
+ If you need to define your own handlers of those events, make sure to call the
174
+ corresponding functions of the `allureCypress`s' return value:
171
175
 
172
- module.exports = {
173
- // ...
176
+ ```javascript
177
+ import { defineConfig } from "cypress";
178
+ import { allureCypress } from "allure-cypress/reporter";
179
+
180
+ export default defineConfig({
174
181
  e2e: {
175
182
  setupNodeEvents: (on, config) => {
176
- + const allureCypress = new AllureCypress({
177
- + resultsDir: "./allure-results",
178
- + });
179
- +
180
- + allureCypress.attachToCypress(on, config);
181
- +
182
- + on("after:spec", (spec, result) => {
183
- + allureCypress.endSpec(spec, result);
184
- + });
185
- +
186
- + return config;
187
- + },
183
+ const allurePlugin = allureCypress(on, config);
184
+
185
+ on("after:spec", (spec, results) => {
186
+ allurePlugin.onAfterSpec(spec, results);
187
+
188
+ // your code ...
189
+ });
190
+
191
+ on("after:run", (results) => {
192
+ allurePlugin.onAfterRun(results);
193
+
194
+ // your code ...
195
+ });
196
+
197
+ return config;
198
+ },
199
+ // ...
188
200
  },
189
- };
201
+ });
190
202
  ```
203
+
204
+ If you want to combine Allure Cypress with other plugins, consider using
205
+ [cypress-on-fix](https://github.com/bahmutov/cypress-on-fix). See the example for
206
+ [the Cypress Cucumber preprocessor](#combining-allure-with-other-cypress-plugins) above.
207
+
208
+ 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).
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var A=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var de=Object.prototype.hasOwnProperty;var ge=(e,t)=>{for(var r in t)A(e,r,{get:t[r],enumerable:!0})},me=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ce(t))!de.call(e,a)&&a!==r&&A(e,a,{get:()=>t[a],enumerable:!(s=le(t,a))||s.enumerable});return e};var fe=e=>me(A({},"__esModule",{value:!0}),e);var Ie={};ge(Ie,{AllureCypressTestRuntime:()=>b,ContentType:()=>G,LabelName:()=>l,LinkType:()=>E,Severity:()=>C,Stage:()=>f,Status:()=>p,StatusByPriority:()=>O,allureId:()=>$,attachment:()=>V,description:()=>H,descriptionHtml:()=>k,displayName:()=>B,epic:()=>J,feature:()=>X,historyId:()=>K,issue:()=>Y,label:()=>g,labels:()=>L,layer:()=>ae,link:()=>R,links:()=>j,owner:()=>re,parameter:()=>U,parentSuite:()=>ee,severity:()=>se,step:()=>W,story:()=>q,subSuite:()=>te,suite:()=>Q,tag:()=>ne,tags:()=>ie,testCaseId:()=>z,tms:()=>Z});module.exports=fe(Ie);var p=function(e){return e.FAILED="failed",e.BROKEN="broken",e.PASSED="passed",e.SKIPPED="skipped",e}({}),O=[p.FAILED,p.BROKEN,p.PASSED,p.SKIPPED],f=function(e){return e.SCHEDULED="scheduled",e.RUNNING="running",e.FINISHED="finished",e.PENDING="pending",e.INTERRUPTED="interrupted",e}({}),l=function(e){return e.ALLURE_ID="ALLURE_ID",e.AS_ID="ALLURE_ID",e.SUITE="suite",e.PARENT_SUITE="parentSuite",e.SUB_SUITE="subSuite",e.EPIC="epic",e.FEATURE="feature",e.STORY="story",e.SEVERITY="severity",e.TAG="tag",e.OWNER="owner",e.LEAD="lead",e.HOST="host",e.THREAD="thread",e.TEST_METHOD="testMethod",e.TEST_CLASS="testClass",e.PACKAGE="package",e.FRAMEWORK="framework",e.LANGUAGE="language",e.LAYER="layer",e}({}),C=function(e){return e.BLOCKER="blocker",e.CRITICAL="critical",e.NORMAL="normal",e.MINOR="minor",e.TRIVIAL="trivial",e}({}),G=function(e){return e.TEXT="text/plain",e.XML="application/xml",e.HTML="text/html",e.CSV="text/csv",e.TSV="text/tab-separated-values",e.CSS="text/css",e.URI="text/uri-list",e.SVG="image/svg+xml",e.PNG="image/png",e.JSON="application/json",e.ZIP="application/zip",e.WEBM="video/webm",e.JPEG="image/jpeg",e.MP4="video/mp4",e.IMAGEDIFF="application/vnd.allure.image.diff",e}({}),E=function(e){return e.ISSUE="issue",e.TMS="tms",e}({});function N(e,t,r,s,a,n,i){try{var u=e[n](i),o=u.value}catch(m){return void r(m)}u.done?t(o):Promise.resolve(o).then(s,a)}function d(e){return function(){var t=this,r=arguments;return new Promise(function(s,a){var n=e.apply(t,r);function i(o){N(n,s,a,i,u,"next",o)}function u(o){N(n,s,a,i,u,"throw",o)}i(void 0)})}}var w=class{attachment(){var t=this;return d(function*(){yield t.warning()})()}description(){var t=this;return d(function*(){yield t.warning()})()}descriptionHtml(){var t=this;return d(function*(){yield t.warning()})()}displayName(){var t=this;return d(function*(){yield t.warning()})()}historyId(){var t=this;return d(function*(){yield t.warning()})()}labels(){var t=this;return d(function*(){yield t.warning()})()}links(){var t=this;return d(function*(){yield t.warning()})()}parameter(){var t=this;return d(function*(){yield t.warning()})()}step(t,r){var s=this;return d(function*(){return yield s.warning(),r()})()}stepDisplayName(){var t=this;return d(function*(){yield t.warning()})()}stepParameter(){var t=this;return d(function*(){yield t.warning()})()}testCaseId(){var t=this;return d(function*(){yield t.warning()})()}warning(){return d(function*(){console.log("no test runtime is found. Please check test framework configuration")})()}},h=new w;var F="allureTestRuntime",T=e=>{globalThis[F]=()=>e},I=()=>globalThis?.[F],v=()=>{var e=I();if(e){var t;return(t=e())!==null&&t!==void 0?t:h}return h},P=()=>{var e=I();if(e){var t;return(t=e())!==null&&t!==void 0?t:h}if("_playwrightInstance"in globalThis)try{return(0,eval)("(() => import('allure-playwright/autoconfig'))()").then(()=>{var r,s;return(r=(s=I())===null||s===void 0?void 0:s())!==null&&r!==void 0?r:h})}catch(r){return console.log("can't execute allure-playwright/autoconfig",r),h}return h};function S(){S=function(n,i){return new r(n,void 0,i)};var e=RegExp.prototype,t=new WeakMap;function r(a,n,i){var u=RegExp(a,n);return t.set(u,i||t.get(a)),x(u,r.prototype)}function s(a,n){var i=t.get(n);return Object.keys(i).reduce(function(u,o){var m=i[o];if(typeof m=="number")u[o]=a[m];else{for(var y=0;a[m[y]]===void 0&&y+1<m.length;)y++;u[o]=a[m[y]]}return u},Object.create(null))}return ye(r,RegExp),r.prototype.exec=function(a){var n=e.exec.call(this,a);if(n){n.groups=s(n,this);var i=n.indices;i&&(i.groups=s(i,this))}return n},r.prototype[Symbol.replace]=function(a,n){if(typeof n=="string"){var i=t.get(this);return e[Symbol.replace].call(this,a,n.replace(/\$<([^>]+)>/g,function(o,m){var y=i[m];return"$"+(Array.isArray(y)?y.join("$"):y)}))}if(typeof n=="function"){var u=this;return e[Symbol.replace].call(this,a,function(){var o=arguments;return typeof o[o.length-1]!="object"&&(o=[].slice.call(o)).push(s(o,u)),n.apply(this,o)})}return e[Symbol.replace].call(this,a,n)},S.apply(this,arguments)}function ye(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&x(e,t)}function x(e,t){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},x(e,t)}var he=S(/@?allure.id[:=]([^\s]+)/,{id:1}),Ge=new RegExp(he,"g"),ve=S(/@?allure.label.([^\s]+?)[:=]([^\s]+)/,{name:1,value:2}),Ne=new RegExp(ve,"g");var _=e=>e.some(t=>t.type==="step_start"||t.type==="step_stop"),Ee=e=>e.reduce((t,r)=>{if(r.type!=="step_start"&&r.type!=="step_stop")return t;if(r.type==="step_start")return t.push([r]),t;var s=t.findLastIndex(a=>a.length===1);return s===-1||t[s].push(r),t},[]),M=e=>{var t=Ee(e);return t.filter(r=>r.length===1)},D=e=>!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function";var c=function(t){for(var r=arguments.length,s=new Array(r>1?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];var n=P();return D(n)?n.then(i=>i[t](...s)):n[t](...s)},g=(e,t)=>c("labels",{name:e,value:t}),L=function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return c("labels",...r)},R=(e,t,r)=>c("links",{url:e,type:t,name:r}),j=function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return c("links",...r)},U=(e,t,r)=>c("parameter",e,t,r),H=e=>c("description",e),k=e=>c("descriptionHtml",e),B=e=>c("displayName",e),K=e=>c("historyId",e),z=e=>c("testCaseId",e),V=(e,t,r)=>c("attachment",e,t,r),Se=()=>({displayName:e=>c("stepDisplayName",e),parameter:(e,t,r)=>c("stepParameter",e,t,r)}),W=(e,t)=>c("step",e,()=>t(Se())),Y=(e,t)=>R(e,E.ISSUE,t),Z=(e,t)=>R(e,E.TMS,t),$=e=>g(l.ALLURE_ID,e),J=e=>g(l.EPIC,e),X=e=>g(l.FEATURE,e),q=e=>g(l.STORY,e),Q=e=>g(l.SUITE,e),ee=e=>g(l.PARENT_SUITE,e),te=e=>g(l.SUB_SUITE,e),re=e=>g(l.OWNER,e),se=e=>g(l.SEVERITY,e),ae=e=>g(l.LAYER,e),ne=e=>g(l.TAG,e),ie=function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return c("labels",...r.map(a=>({name:l.TAG,value:a})))};var oe=e=>Array.isArray(e)||e.buffer?btoa(String.fromCharCode.apply(null,e)):e,ue=(e,t)=>Array.isArray(e)||e.buffer?"base64":t,pe=e=>{let t=[],r=e.parent;for(;r;)r.title&&t.unshift(r.title),r=r.parent;return t};var b=class{label(t,r){return this.sendMessageAsync({type:"metadata",data:{labels:[{name:t,value:r}]}})}labels(...t){return this.sendMessageAsync({type:"metadata",data:{labels:t}})}link(t,r,s){return this.sendMessageAsync({type:"metadata",data:{links:[{type:r,url:t,name:s}]}})}links(...t){return this.sendMessageAsync({type:"metadata",data:{links:t}})}parameter(t,r,s){return this.sendMessageAsync({type:"metadata",data:{parameters:[{name:t,value:r,...s}]}})}description(t){return this.sendMessageAsync({type:"metadata",data:{description:t}})}descriptionHtml(t){return this.sendMessageAsync({type:"metadata",data:{descriptionHtml:t}})}displayName(t){return this.sendMessageAsync({type:"metadata",data:{displayName:t}})}historyId(t){return this.sendMessageAsync({type:"metadata",data:{historyId:t}})}testCaseId(t){return this.sendMessageAsync({type:"metadata",data:{testCaseId:t}})}attachment(t,r,s){let a=r?.type==="Buffer"?r.data:r,n=r instanceof Buffer?"base64":"utf-8",i=ue(a,n),u=oe(a);return this.sendMessageAsync({type:"raw_attachment",data:{content:u,encoding:i,contentType:s,name:t}})}step(t,r){return cy.wrap(null,{log:!1}).then(()=>(this.sendMessage({type:"step_start",data:{name:t,start:Date.now()}}),Cypress.Promise.resolve(r()))).then(s=>this.sendMessageAsync({type:"step_stop",data:{status:p.PASSED,stage:f.FINISHED,stop:Date.now()}}).then(()=>s))}stepDisplayName(t){return this.sendMessageAsync({type:"step_metadata",data:{name:t}})}stepParameter(t,r,s){return this.sendMessageAsync({type:"step_metadata",data:{parameters:[{name:t,value:r,mode:s}]}})}sendMessage(t){let r=Cypress.env("allureRuntimeMessages")||[];Cypress.env("allureRuntimeMessages",r.concat(t))}sendMessageAsync(t){return this.sendMessage(t),Cypress.Promise.resolve()}},{EVENT_TEST_BEGIN:Re,EVENT_TEST_FAIL:be,EVENT_TEST_PASS:Ae}=Mocha.Runner.constants,we=()=>{Cypress.env("allureInitialized")||(Cypress.mocha.getRunner().on(Re,t=>{let r=new b;Cypress.env("allureRuntimeMessages",[]),r.sendMessage({type:"cypress_start",data:{isInteractive:Cypress.config("isInteractive"),absolutePath:Cypress.spec.absolute,specPath:pe(t).concat(t.title),filename:Cypress.spec.relative,start:Date.now()}}),T(r)}).on(Ae,()=>{let t=v(),r=Cypress.env("allureRuntimeMessages");M(r).forEach(()=>{t.sendMessage({type:"step_stop",data:{stage:f.FINISHED,status:p.PASSED,stop:Date.now()}})}),t.sendMessage({type:"cypress_end",data:{stage:f.FINISHED,status:p.PASSED,stop:Date.now()}})}).on(be,(t,r)=>{v().sendMessage({type:"cypress_end",data:{stage:f.FINISHED,status:r.constructor.name==="AssertionError"?p.FAILED:p.BROKEN,statusDetails:{message:r.message,trace:r.stack},stop:Date.now()}})}),Cypress.Screenshot.defaults({onAfterScreenshot:(t,r)=>{v().sendMessage({type:"cypress_screenshot",data:{path:r.path,name:r.name||"Screenshot"}})}}),Cypress.on("fail",t=>{let r=v(),s=Cypress.env("allureRuntimeMessages");if(!_(s))throw t;let n=M(s);if(n.length===0)throw t;let i=t.constructor.name==="AssertionError"?p.FAILED:p.BROKEN;throw n.forEach(()=>{r.sendMessage({type:"step_stop",data:{stage:f.FINISHED,status:i,stop:Date.now(),statusDetails:{message:t.message,trace:t.stack}}})}),t}),afterEach(()=>{let t=Cypress.env("allureRuntimeMessages");cy.task("allureReportTest",t,{log:!1})}),Cypress.env("allureInitialized",!0))};we();
1
+ "use strict";var D=Object.defineProperty;var Ze=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var Xe=Object.prototype.hasOwnProperty;var Qe=(e,t)=>{for(var r in t)D(e,r,{get:t[r],enumerable:!0})},et=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Je(t))!Xe.call(e,a)&&a!==r&&D(e,a,{get:()=>t[a],enumerable:!(s=Ze(t,a))||s.enumerable});return e};var tt=e=>et(D({},"__esModule",{value:!0}),e);var At={};Qe(At,{ContentType:()=>b,LabelName:()=>u,LinkType:()=>E,Severity:()=>$,Stage:()=>W,Status:()=>l,StatusByPriority:()=>Y,allureId:()=>me,attachment:()=>ie,attachmentPath:()=>pe,description:()=>re,descriptionHtml:()=>se,displayName:()=>ae,epic:()=>ye,feature:()=>ge,historyId:()=>ne,issue:()=>ce,label:()=>y,labels:()=>Q,layer:()=>xe,link:()=>P,links:()=>ee,logStep:()=>ue,owner:()=>Te,parameter:()=>te,parentSuite:()=>ve,severity:()=>Ee,step:()=>le,story:()=>fe,subSuite:()=>Se,suite:()=>he,tag:()=>_e,tags:()=>Me,testCaseId:()=>oe,tms:()=>de});module.exports=tt(At);var l=function(e){return e.FAILED="failed",e.BROKEN="broken",e.PASSED="passed",e.SKIPPED="skipped",e}({}),Y=[l.FAILED,l.BROKEN,l.PASSED,l.SKIPPED],W=function(e){return e.SCHEDULED="scheduled",e.RUNNING="running",e.FINISHED="finished",e.PENDING="pending",e.INTERRUPTED="interrupted",e}({}),u=function(e){return e.ALLURE_ID="ALLURE_ID",e.AS_ID="ALLURE_ID",e.SUITE="suite",e.PARENT_SUITE="parentSuite",e.SUB_SUITE="subSuite",e.EPIC="epic",e.FEATURE="feature",e.STORY="story",e.SEVERITY="severity",e.TAG="tag",e.OWNER="owner",e.LEAD="lead",e.HOST="host",e.THREAD="thread",e.TEST_METHOD="testMethod",e.TEST_CLASS="testClass",e.PACKAGE="package",e.FRAMEWORK="framework",e.LANGUAGE="language",e.LAYER="layer",e}({}),$=function(e){return e.BLOCKER="blocker",e.CRITICAL="critical",e.NORMAL="normal",e.MINOR="minor",e.TRIVIAL="trivial",e}({}),b=function(e){return e.TEXT="text/plain",e.XML="application/xml",e.HTML="text/html",e.CSV="text/csv",e.TSV="text/tab-separated-values",e.CSS="text/css",e.URI="text/uri-list",e.SVG="image/svg+xml",e.PNG="image/png",e.JSON="application/json",e.ZIP="application/zip",e.WEBM="video/webm",e.JPEG="image/jpeg",e.MP4="video/mp4",e.IMAGEDIFF="application/vnd.allure.image.diff",e}({}),E=function(e){return e.DEFAULT="link",e.ISSUE="issue",e.TMS="tms",e}({});function C(){C=function(n,o){return new r(n,void 0,o)};var e=RegExp.prototype,t=new WeakMap;function r(a,n,o){var i=RegExp(a,n);return t.set(i,o||t.get(a)),R(i,r.prototype)}function s(a,n){var o=t.get(n);return Object.keys(o).reduce(function(i,p){var g=o[p];if(typeof g=="number")i[p]=a[g];else{for(var f=0;a[g[f]]===void 0&&f+1<g.length;)f++;i[p]=a[g[f]]}return i},Object.create(null))}return rt(r,RegExp),r.prototype.exec=function(a){var n=e.exec.call(this,a);if(n){n.groups=s(n,this);var o=n.indices;o&&(o.groups=s(o,this))}return n},r.prototype[Symbol.replace]=function(a,n){if(typeof n=="string"){var o=t.get(this);return e[Symbol.replace].call(this,a,n.replace(/\$<([^>]+)>/g,function(p,g){var f=o[g];return"$"+(Array.isArray(f)?f.join("$"):f)}))}if(typeof n=="function"){var i=this;return e[Symbol.replace].call(this,a,function(){var p=arguments;return typeof p[p.length-1]!="object"&&(p=[].slice.call(p)).push(s(p,i)),n.apply(this,p)})}return e[Symbol.replace].call(this,a,n)},C.apply(this,arguments)}function rt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&R(e,t)}function R(e,t){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,s){return r.__proto__=s,r},R(e,t)}var v=e=>{switch(!0){case/assert/gi.test(e.constructor.name):case/expectation/gi.test(e.constructor.name):case/assert/gi.test(e.name):case/assert/gi.test(e.message):return l.FAILED;default:return l.BROKEN}},st=function(){var{onlyFirst:t=!1}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(r,t?void 0:"g")},I=e=>{var t=st();return e.replace(t,"")},h=e=>{var{message:t,stack:r}=e;return{message:t?I(t):void 0,trace:r?I(r):void 0}},q=C(/(?:^|\s)@?allure\.id[:=]([^\s]+)/,{id:1}),at=new RegExp(q,"g"),Z=C(/(?:^|\s)@?allure\.label\.([^:=\s]+)[:=]([^\s]+)/,{name:1,value:2}),nt=new RegExp(Z,"g");var k=e=>{var t=[];e.split(" ").forEach(s=>{var a,n=(a=s.match(q))===null||a===void 0||(a=a.groups)===null||a===void 0?void 0:a.id;n&&t.push({name:u.ALLURE_ID,value:n});var o=s.match(Z),{name:i,value:p}=o?.groups||{};i&&p&&t?.push({name:i,value:p})});var r=e.replace(nt,"").replace(at,"").trim();return{labels:t,cleanTitle:r}};var ot=e=>e.reduce((t,r)=>{if(r.type!=="step_start"&&r.type!=="step_stop")return t;if(r.type==="step_start")return t.push([r]),t;var s=t.findLastIndex(a=>a.length===1);return s===-1||t[s].push(r),t},[]),O=e=>{var t=ot(e);return t.filter(r=>r.length===1)},F=e=>!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function";var S="__allure_report_system_hook__",x="__allure_report_step_command__";function J(e,t,r,s,a,n,o){try{var i=e[n](o),p=i.value}catch(g){return void r(g)}i.done?t(p):Promise.resolve(p).then(s,a)}function m(e){return function(){var t=this,r=arguments;return new Promise(function(s,a){var n=e.apply(t,r);function o(p){J(n,s,a,o,i,"next",p)}function i(p){J(n,s,a,o,i,"throw",p)}o(void 0)})}}var N=class{attachment(){var t=this;return m(function*(){yield t.warning()})()}attachmentFromPath(){var t=this;return m(function*(){yield t.warning()})()}description(){var t=this;return m(function*(){yield t.warning()})()}descriptionHtml(){var t=this;return m(function*(){yield t.warning()})()}displayName(){var t=this;return m(function*(){yield t.warning()})()}historyId(){var t=this;return m(function*(){yield t.warning()})()}labels(){var t=this;return m(function*(){yield t.warning()})()}links(){var t=this;return m(function*(){yield t.warning()})()}parameter(){var t=this;return m(function*(){yield t.warning()})()}logStep(){var t=this;return m(function*(){yield t.warning()})()}step(t,r){var s=this;return m(function*(){return yield s.warning(),r()})()}stepDisplayName(){var t=this;return m(function*(){yield t.warning()})()}stepParameter(){var t=this;return m(function*(){yield t.warning()})()}testCaseId(){var t=this;return m(function*(){yield t.warning()})()}warning(){return m(function*(){console.log("no test runtime is found. Please check test framework configuration")})()}},T=new N;var X="allureTestRuntime",L=e=>{globalThis[X]=()=>e},H=()=>globalThis?.[X],U=()=>{var e=H();if(e){var t;return(t=e())!==null&&t!==void 0?t:T}return T},j=()=>{var e=H();if(e){var t;return(t=e())!==null&&t!==void 0?t:T}if("_playwrightInstance"in globalThis)try{return(0,eval)("(() => import('allure-playwright/autoconfig'))()").then(()=>{var r,s;return(r=(s=H())===null||s===void 0?void 0:s())!==null&&r!==void 0?r:T})}catch(r){return console.log("can't execute allure-playwright/autoconfig",r),T}return T};var c=function(t){for(var r=arguments.length,s=new Array(r>1?r-1:0),a=1;a<r;a++)s[a-1]=arguments[a];var n=j();return F(n)?n.then(o=>o[t](...s)):n[t](...s)},y=(e,t)=>c("labels",{name:e,value:t}),Q=function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return c("labels",...r)},P=(e,t,r)=>c("links",{url:e,type:r,name:t}),ee=function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return c("links",...r)},te=(e,t,r)=>c("parameter",e,t,r),re=e=>c("description",e),se=e=>c("descriptionHtml",e),ae=e=>c("displayName",e),ne=e=>c("historyId",e),oe=e=>c("testCaseId",e),ie=(e,t,r)=>{var s=typeof r=="string"?{contentType:r}:r;return c("attachment",e,t,s)},pe=(e,t,r)=>{var s=typeof r=="string"?{contentType:r}:r;return c("attachmentFromPath",e,t,s)},it=()=>({displayName:e=>c("stepDisplayName",e),parameter:(e,t,r)=>c("stepParameter",e,t,r)}),ue=(e,t,r)=>c("logStep",e,t,r),le=(e,t)=>c("step",e,()=>t(it())),ce=(e,t)=>P(e,t,E.ISSUE),de=(e,t)=>P(e,t,E.TMS),me=e=>y(u.ALLURE_ID,e),ye=e=>y(u.EPIC,e),ge=e=>y(u.FEATURE,e),fe=e=>y(u.STORY,e),he=e=>y(u.SUITE,e),ve=e=>y(u.PARENT_SUITE,e),Se=e=>y(u.SUB_SUITE,e),Te=e=>y(u.OWNER,e),Ee=e=>y(u.SEVERITY,e),xe=e=>y(u.LAYER,e),_e=e=>y(u.TAG,e),Me=function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return c("labels",...r.map(a=>({name:u.TAG,value:a})))};var _=()=>{let e=Cypress.env("allure");return e||(e={initialized:!1,messages:[],testPlan:void 0},Cypress.env("allure",e)),e},be=()=>_().initialized,Ce=()=>{_().initialized=!0},M=()=>_().messages,Re=e=>{_().messages=e},d=e=>{M().push(e)},Pe=()=>_().testPlan;var Ae=e=>Array.isArray(e)||e.buffer?btoa(String.fromCharCode.apply(null,e)):e;var G=e=>ut(e.attributes.args)?.log===!1||e.attributes.name==="task"&&e.attributes.args[0]==="reportAllureRuntimeMessages"||e.attributes.name==="then"||e.attributes.name==="wrap"&&e.attributes.args[0]===x;var ut=e=>e[e.length-1],V=(e,t)=>{let r=t.title,{cleanTitle:s,labels:a}=k(r),n=t.titlePath().slice(0,-1),o=`${e.relative}#${[...n,s].join(" ")}`;return{name:s,labels:a,fullName:o}},we=(e,t)=>{let r=Pe();if(r){let s=[];for(let a=t;a;a=s.shift()){let n=ct(r,e,a.tests);dt(a.tests,n),s.push(...a.suites)}}};var De=Symbol("The test was reported to Allure"),Ie=e=>{e[De]=!0},A=e=>e[De]===!0;var lt=(e,t,r)=>e.tests.some(s=>r&&s.id?.toString()===r||s.selector===t),ct=(e,t,r)=>{let s=[];return r.forEach((a,n)=>{let{fullName:o,labels:i}=V(t,a),p=i.find(({name:g})=>g===u.ALLURE_ID)?.value;lt(e,o,p)||s.push(n)}),s},dt=(e,t)=>{for(let r=t.length-1;r>=0;r--)e.splice(t[r],1)};var B=class{constructor(){this.#r()}labels(...t){return this.#e({type:"metadata",data:{labels:t}})}links(...t){return this.#e({type:"metadata",data:{links:t}})}parameter(t,r,s){return this.#e({type:"metadata",data:{parameters:[{name:t,value:r,...s}]}})}description(t){return this.#e({type:"metadata",data:{description:t}})}descriptionHtml(t){return this.#e({type:"metadata",data:{descriptionHtml:t}})}displayName(t){return this.#e({type:"metadata",data:{displayName:t}})}historyId(t){return this.#e({type:"metadata",data:{historyId:t}})}testCaseId(t){return this.#e({type:"metadata",data:{testCaseId:t}})}attachment(t,r,s){let a=r?.type==="Buffer"?r.data:r,n=typeof a=="string"?"utf8":"base64",o=Ae(a);return this.#e({type:"attachment_content",data:{name:t,content:o,encoding:n,contentType:s.contentType,fileExtension:s.fileExtension}})}attachmentFromPath(t,r,s){return this.#e({type:"attachment_path",data:{name:t,path:r,contentType:s.contentType,fileExtension:s.fileExtension}})}logStep(t,r=l.PASSED,s){return cy.wrap(x,{log:!1}).then(()=>(this.#e({type:"step_start",data:{name:t,start:Date.now()}}),Cypress.Promise.resolve())).then(()=>this.#e({type:"step_stop",data:{status:r,stop:Date.now(),statusDetails:s?{...h(s)}:void 0}}))}step(t,r){return cy.wrap(x,{log:!1}).then(()=>(this.#e({type:"step_start",data:{name:t,start:Date.now()}}),Cypress.Promise.resolve(r()))).then(s=>this.#e({type:"step_stop",data:{status:l.PASSED,stop:Date.now()}}).then(()=>s))}stepDisplayName(t){return this.#e({type:"step_metadata",data:{name:t}})}stepParameter(t,r,s){return this.#e({type:"step_metadata",data:{parameters:[{name:t,value:r,mode:s}]}})}flushMessages=()=>this.#t("reportAllureCypressSpecMessages");flushFinalMessages=()=>this.#t("reportFinalAllureCypressSpecMessages");#t=t=>{let r=this.#s();return r.length?cy.task(t,{absolutePath:Cypress.spec.absolute,messages:r},{log:!1}):Cypress.Promise.resolve()};#r=()=>Re([]);#e=t=>(d(t),Cypress.Promise.resolve());#s=()=>{let t=M();return this.#r(),t}},ke=()=>L(new B),Oe=()=>U(),w=()=>Oe().flushMessages(),Fe=()=>Oe().flushFinalMessages(),Ne=()=>{d({type:"cypress_run_start",data:{}})},He=e=>{d({type:"cypress_suite_start",data:{name:e.title,root:!e.parent,start:Date.now()}})},Le=e=>{d({type:"cypress_suite_end",data:{root:!e.parent,stop:Date.now()}})},Ue=e=>{d({type:"cypress_hook_start",data:{name:e.title,start:Date.now()}})},je=e=>{d({type:"cypress_hook_end",data:{duration:e.duration??0}})},K=(e,t)=>{let r=V(Cypress.spec,e);t&&r.labels.push({name:"reported",value:t}),d({type:"cypress_test_start",data:{...r,start:e.wallClockStartedAt?.getTime()||Date.now()}}),Ie(e)},z=(e,t)=>{let r=M();O(r).forEach(()=>{d({type:"step_stop",data:{stop:Date.now(),status:e,statusDetails:t}})})},Ge=()=>{z(l.PASSED),d({type:"cypress_test_pass",data:{}})},Ve=e=>{A(e)?Ye(l.SKIPPED,{message:"The test was skipped before the command was completed"}):K(e),d({type:"cypress_test_skip",data:{}})},Be=e=>{d({type:"cypress_command_start",data:{name:`Command "${e.attributes.name}"`,args:e.attributes.args.map(t=>typeof t=="string"?t:JSON.stringify(t,null,2)),start:Date.now()}})},Ke=()=>{d({type:"cypress_command_end",data:{status:l.PASSED,stop:Date.now()}})},ze=(e,t)=>{d({type:"attachment_path",data:{path:e,name:t||"Screenshot",contentType:b.PNG}})},Ye=(e,t)=>{let r=M(),s=r.toReversed().findIndex(({type:i})=>i==="cypress_command_start"),a=r.toReversed().findIndex(({type:i})=>i==="cypress_command_end"),n=s>a,o={status:e,stop:Date.now()};t&&(o.statusDetails=t),n&&d({type:"cypress_command_end",data:o})},We=e=>{let t=v(e),r=h(e);Ye(t,r),d({type:"cypress_fail",data:{status:t,statusDetails:r}})},$e=e=>{d({type:"cypress_test_end",data:{duration:e.duration??0,retries:e._retries??0}})},mt=(e,...t)=>{let[r,s,a]=t;return typeof a>"u"&&typeof s>"u"?e(r):typeof s=="function"?e(r,s):e(r,s,a)},yt=(e,t)=>{let r=n=>(o,i,p)=>{e();try{return mt(n,o,i,p)}finally{t()}},s=globalThis.describe,a=r(s);a.only=r(s.only),a.skip=r(s.skip),globalThis.describe=a},gt=()=>{let e=0;return[()=>e,()=>{e++},()=>{e--}]},ft=e=>{let t=globalThis.after,r=(s,a)=>{try{return typeof s=="string"?t(s,a):t(s)}finally{e()===0&&t(S,()=>{w()})}};globalThis.after=r},qe=()=>{let[e,t,r]=gt();yt(t,r),ft(e)};var{EVENT_RUN_BEGIN:ht,EVENT_SUITE_BEGIN:vt,EVENT_SUITE_END:St,EVENT_HOOK_BEGIN:Tt,EVENT_HOOK_END:Et,EVENT_TEST_BEGIN:xt,EVENT_TEST_PASS:_t,EVENT_TEST_FAIL:Mt,EVENT_TEST_PENDING:bt,EVENT_TEST_END:Ct,EVENT_RUN_END:Rt}=Mocha.Runner.constants,Pt=()=>{be()||(Ce(),Cypress.mocha.getRunner().on(ht,()=>{ke(),Ne()}).on(vt,e=>{e.parent||we(Cypress.spec,e),He(e)}).on(St,e=>{Le(e)}).on(Tt,e=>{e.title.includes(S)||Ue(e)}).on(Et,e=>{e.title.includes(S)||je(e)}).on(xt,e=>{A(e)||K(e)}).on(_t,()=>{Ge()}).on(Mt,(e,t)=>{We(t)}).on(bt,e=>{Ve(e)}).on(Ct,e=>{$e(e)}).on(Rt,()=>{Cypress.config("isInteractive")&&Fe()}),Cypress.Screenshot.defaults({onAfterScreenshot:(e,{path:t,name:r})=>{ze(t,r)}}),Cypress.on("fail",e=>{let t=v(e),r=h(e);throw z(t,r),e}),Cypress.on("command:start",e=>{G(e)||Be(e)}),Cypress.on("command:end",e=>{G(e)||Ke()}),afterEach(S,()=>{w()}),after(S,()=>{w()}),qe())};Pt();
2
2
  //# sourceMappingURL=index.js.map