allure-cypress 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,158 @@
1
+ # allure-cypress
2
+
3
+ > Allure framework integration for Cypress
4
+
5
+ [<img src="https://allurereport.org/public/img/allure-report.svg" height="85px" alt="Allure Report logo" align="right" />](https://allurereport.org "Allure Report")
6
+
7
+ - Learn more about Allure Report at https://allurereport.org
8
+ - 📚 [Documentation](https://allurereport.org/docs/) – discover official documentation for Allure Report
9
+ - ❓ [Questions and Support](https://github.com/orgs/allure-framework/discussions/categories/questions-support) – get help from the team and community
10
+ - 📢 [Official annoucements](https://github.com/orgs/allure-framework/discussions/categories/announcements) – be in touch with the latest updates
11
+ - 💬 [General Discussion ](https://github.com/orgs/allure-framework/discussions/categories/general-discussion) – engage in casual conversations, share insights and ideas with the community
12
+
13
+ ---
14
+
15
+ ## Installation
16
+
17
+ Use your favorite node package manager to install the required packages:
18
+
19
+ ```shell
20
+ npm add -D allure-cypress
21
+ ```
22
+
23
+ Add the following lines to your `cypress.config.js` file to setup the reporter:
24
+
25
+ ```diff
26
+ const { allureCypress } = require("allure-cypress/reporter");
27
+
28
+ module.exports = {
29
+ // ...
30
+ e2e: {
31
+ + setupNodeEvents: (on, config) => {
32
+ + allureCypress(on, {
33
+ + resultsDir: "./allure-results",
34
+ + });
35
+ +
36
+ + return config;
37
+ + },
38
+ },
39
+ };
40
+ ```
41
+
42
+ Don't forget to add the Allure Cypress commands to your `cypress/support/e2e.js` file to finish
43
+ the installation:
44
+
45
+ ```diff
46
+ + import "allure-cypress/commands";
47
+ ```
48
+
49
+ ## Use Allure runtime Api
50
+
51
+ The plugin provides custom commands which allow to add additional info inside your tests:
52
+
53
+ ```javascript
54
+ import { epic, attachment, parameter } from "allure-cypress";
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
+ ```
65
+
66
+ ## Links usage
67
+
68
+ ```js
69
+ import { link, issue, tms } from "allure-cypress";
70
+
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
+ });
76
+ ```
77
+
78
+ You can also configure links formatters to make usage much more convenient. `%s`
79
+ in `urlTemplate` parameter will be replaced by given value.
80
+
81
+ ```diff
82
+ const { allureCypress } = require("allure-cypress/reporter");
83
+
84
+ module.exports = {
85
+ // ...
86
+ e2e: {
87
+ setupNodeEvents: (on, config) => {
88
+ allureCypress(on, {
89
+ + links: [
90
+ + {
91
+ + type: "issue",
92
+ + urlTemplate: "https://example.org/issues/%s"
93
+ + },
94
+ + {
95
+ + type: "tms",
96
+ + urlTemplate: "https://example.org/tasks/%s"
97
+ + },
98
+ + {
99
+ + type: "custom",
100
+ + urlTemplate: "https://example.org/custom/%s"
101
+ + },
102
+ + ],
103
+ + });
104
+
105
+ return config;
106
+ },
107
+ },
108
+ };
109
+ ```
110
+
111
+ Then you can assign link using shorter notation:
112
+
113
+ ```js
114
+ import { link, issue, tms } from "allure-cypress";
115
+
116
+ it("basic test", () => {
117
+ issue("351");
118
+ issue("352", "Issue Name");
119
+ tms("351");
120
+ tms("352", "Task Name");
121
+ link("custom", "352");
122
+ link("custom", "352", "Link name");
123
+ });
124
+ ```
125
+
126
+ ## Steps usage
127
+
128
+ The integration supports Allure steps, use them in following way:
129
+
130
+ ```js
131
+ import { step } from "allure-cypress";
132
+
133
+ it("my test", () => {
134
+ step("foo", () => {
135
+ step("bar", () => {
136
+ step("baz", () => {
137
+ cy.log("my cypress commands");
138
+ });
139
+ });
140
+ });
141
+ });
142
+ ```
143
+
144
+ ## Passing metadata from test title
145
+
146
+ You also can pass allure metadata from test title.
147
+ 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.
148
+
149
+ ```ts
150
+ it("test with allureId @allure.id=256", () => {});
151
+ it("tst with severity @allure.label.severity=critical", () => {});
152
+ it("test with epic @allure.label.epic=login", () => {});
153
+ it("test with strangeLabel @allure.label.strangeLabel=strangeValue", () => {});
154
+ ```
155
+
156
+ > **Warning**
157
+ > Note that changing title can cause creating new testcases in history.
158
+ > To fix this please add `@allure.id={yourTestCaseId}` to the test name if you passing allure metadata from test title
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,121 @@
1
+ // src/commands.ts
2
+ var createFinalMesage = () => ({
3
+ startMessage: void 0,
4
+ endMessage: void 0,
5
+ messages: []
6
+ });
7
+ var { EVENT_TEST_BEGIN, EVENT_TEST_FAIL, EVENT_TEST_PASS } = Mocha.Runner.constants;
8
+ var getSuitePath = (test) => {
9
+ const path = [];
10
+ let currentSuite = test.parent;
11
+ while (currentSuite) {
12
+ if (currentSuite.title) {
13
+ path.unshift(currentSuite.title);
14
+ }
15
+ currentSuite = currentSuite.parent;
16
+ }
17
+ return path;
18
+ };
19
+ var getStepsMessagesPair = (reportMessage) => reportMessage.messages.reduce((acc, message) => {
20
+ if (message.type !== "STEP_STARTED" /* STEP_STARTED */ && message.type !== "STEP_ENDED" /* STEP_ENDED */) {
21
+ return acc;
22
+ }
23
+ if (message.type === "STEP_STARTED" /* STEP_STARTED */) {
24
+ acc.push([message]);
25
+ return acc;
26
+ }
27
+ const unfinishedStepIdx = acc.findLastIndex((step) => step.length === 1);
28
+ if (unfinishedStepIdx === -1) {
29
+ return acc;
30
+ }
31
+ acc[unfinishedStepIdx].push(message);
32
+ return acc;
33
+ }, []);
34
+ Cypress.mocha.getRunner().on(EVENT_TEST_BEGIN, (test) => {
35
+ const reportMessage = createFinalMesage();
36
+ reportMessage.startMessage = {
37
+ specPath: getSuitePath(test).concat(test.title),
38
+ filename: Cypress.spec.relative,
39
+ start: Date.now()
40
+ };
41
+ Cypress.env("allure", { reportMessage });
42
+ }).on(EVENT_TEST_PASS, () => {
43
+ const reportMessage = Cypress.env("allure").reportMessage;
44
+ const grouppedStepsMessage = getStepsMessagesPair(reportMessage);
45
+ const unfinishedStepsMessages = grouppedStepsMessage.filter((step) => step.length === 1);
46
+ unfinishedStepsMessages.forEach(() => {
47
+ reportMessage.messages.push({
48
+ type: "STEP_ENDED" /* STEP_ENDED */,
49
+ payload: {
50
+ stage: "finished" /* FINISHED */,
51
+ status: "passed" /* PASSED */,
52
+ stop: Date.now()
53
+ }
54
+ });
55
+ });
56
+ reportMessage.endMessage = {
57
+ stage: "finished" /* FINISHED */,
58
+ status: "passed" /* PASSED */,
59
+ stop: Date.now()
60
+ };
61
+ Cypress.env("allure", { reportMessage });
62
+ }).on(EVENT_TEST_FAIL, (test, err) => {
63
+ const reportMessage = Cypress.env("allure").reportMessage;
64
+ reportMessage.endMessage = {
65
+ stage: "finished" /* FINISHED */,
66
+ status: err.constructor.name === "AssertionError" ? "failed" /* FAILED */ : "broken" /* BROKEN */,
67
+ statusDetails: {
68
+ message: err.message,
69
+ trace: err.stack
70
+ },
71
+ stop: Date.now()
72
+ };
73
+ Cypress.env("allure", { reportMessage });
74
+ });
75
+ Cypress.Screenshot.defaults({
76
+ onAfterScreenshot: (_, details) => {
77
+ const reportMessage = Cypress.env("allure").reportMessage;
78
+ reportMessage.messages.push({
79
+ type: "SCREENSHOT" /* SCREENSHOT */,
80
+ payload: {
81
+ path: details.path,
82
+ name: details.name || "Screenshot"
83
+ }
84
+ });
85
+ Cypress.env("allure", { reportMessage });
86
+ }
87
+ });
88
+ Cypress.on("fail", (err) => {
89
+ const reportMessage = Cypress.env("allure").reportMessage;
90
+ const hasSteps = reportMessage.messages.some((message) => message.type === "STEP_STARTED" /* STEP_STARTED */);
91
+ if (!hasSteps) {
92
+ throw err;
93
+ }
94
+ const grouppedStepsMessage = getStepsMessagesPair(reportMessage);
95
+ const unfinishedStepsMessages = grouppedStepsMessage.filter((step) => step.length === 1);
96
+ if (unfinishedStepsMessages.length === 0) {
97
+ throw err;
98
+ }
99
+ const failedStepsStatus = err.constructor.name === "AssertionError" ? "failed" /* FAILED */ : "broken" /* BROKEN */;
100
+ unfinishedStepsMessages.forEach(() => {
101
+ reportMessage.messages.push({
102
+ type: "STEP_ENDED" /* STEP_ENDED */,
103
+ payload: {
104
+ stage: "finished" /* FINISHED */,
105
+ status: failedStepsStatus,
106
+ stop: Date.now(),
107
+ statusDetails: {
108
+ message: err.message,
109
+ trace: err.stack
110
+ }
111
+ }
112
+ });
113
+ });
114
+ Cypress.env("allure", { reportMessage });
115
+ throw err;
116
+ });
117
+ afterEach(() => {
118
+ const reportMessage = Cypress.env("allure").reportMessage;
119
+ cy.task("allureReportTest", reportMessage, { log: false });
120
+ });
121
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/commands.ts"],
4
+ "sourcesContent": ["import { MessageType, type ReportFinalMessage, Stage, Status } from \"./model\";\n\nconst createFinalMesage = () =>\n ({\n startMessage: undefined,\n endMessage: undefined,\n messages: [],\n }) as ReportFinalMessage;\n\nconst { EVENT_TEST_BEGIN, EVENT_TEST_FAIL, EVENT_TEST_PASS } = Mocha.Runner.constants;\n\nconst getSuitePath = (test: Mocha.Test): string[] => {\n const path: string[] = [];\n let currentSuite: Mocha.Suite | undefined = test.parent;\n\n while (currentSuite) {\n if (currentSuite.title) {\n path.unshift(currentSuite.title);\n }\n\n currentSuite = currentSuite.parent;\n }\n\n return path;\n};\nconst getStepsMessagesPair = (reportMessage: ReportFinalMessage) =>\n reportMessage.messages.reduce((acc, message) => {\n if (message.type !== MessageType.STEP_STARTED && message.type !== MessageType.STEP_ENDED) {\n return acc;\n }\n\n if (message.type === MessageType.STEP_STARTED) {\n acc.push([message]);\n\n return acc;\n }\n\n const unfinishedStepIdx = acc.findLastIndex((step) => step.length === 1);\n\n if (unfinishedStepIdx === -1) {\n return acc;\n }\n\n acc[unfinishedStepIdx].push(message);\n\n return acc;\n }, []);\n\n// @ts-ignore\nCypress.mocha\n .getRunner()\n .on(EVENT_TEST_BEGIN, (test: Mocha.Test) => {\n const reportMessage = createFinalMesage();\n\n reportMessage.startMessage = {\n specPath: getSuitePath(test).concat(test.title),\n filename: Cypress.spec.relative,\n start: Date.now(),\n };\n\n Cypress.env(\"allure\", { reportMessage });\n })\n .on(EVENT_TEST_PASS, () => {\n const reportMessage: ReportFinalMessage = Cypress.env(\"allure\").reportMessage;\n const grouppedStepsMessage = getStepsMessagesPair(reportMessage);\n const unfinishedStepsMessages = grouppedStepsMessage.filter((step) => step.length === 1);\n\n unfinishedStepsMessages.forEach(() => {\n reportMessage.messages.push({\n type: MessageType.STEP_ENDED,\n payload: {\n stage: Stage.FINISHED,\n status: Status.PASSED,\n stop: Date.now(),\n },\n });\n });\n reportMessage.endMessage = {\n stage: Stage.FINISHED,\n status: Status.PASSED,\n stop: Date.now(),\n };\n\n Cypress.env(\"allure\", { reportMessage });\n })\n .on(EVENT_TEST_FAIL, (test: Mocha.Test, err: Error) => {\n const reportMessage: ReportFinalMessage = Cypress.env(\"allure\").reportMessage;\n\n reportMessage.endMessage = {\n stage: Stage.FINISHED,\n status: err.constructor.name === \"AssertionError\" ? Status.FAILED : Status.BROKEN,\n statusDetails: {\n message: err.message,\n trace: err.stack,\n },\n stop: Date.now(),\n };\n\n Cypress.env(\"allure\", { reportMessage });\n });\n\nCypress.Screenshot.defaults({\n onAfterScreenshot: (_, details) => {\n const reportMessage: ReportFinalMessage = Cypress.env(\"allure\").reportMessage;\n\n reportMessage.messages.push({\n type: MessageType.SCREENSHOT,\n payload: {\n path: details.path,\n name: details.name || \"Screenshot\",\n },\n });\n\n Cypress.env(\"allure\", { reportMessage });\n },\n});\nCypress.on(\"fail\", (err) => {\n const reportMessage: ReportFinalMessage = Cypress.env(\"allure\").reportMessage;\n const hasSteps = reportMessage.messages.some((message) => message.type === MessageType.STEP_STARTED);\n\n // if there is no steps, don't handle the error\n if (!hasSteps) {\n throw err;\n }\n\n const grouppedStepsMessage = getStepsMessagesPair(reportMessage);\n const unfinishedStepsMessages = grouppedStepsMessage.filter((step) => step.length === 1);\n\n if (unfinishedStepsMessages.length === 0) {\n throw err;\n }\n\n const failedStepsStatus = err.constructor.name === \"AssertionError\" ? Status.FAILED : Status.BROKEN;\n\n unfinishedStepsMessages.forEach(() => {\n reportMessage.messages.push({\n type: MessageType.STEP_ENDED,\n payload: {\n stage: Stage.FINISHED,\n status: failedStepsStatus,\n stop: Date.now(),\n statusDetails: {\n message: err.message,\n trace: err.stack,\n },\n },\n });\n });\n\n Cypress.env(\"allure\", { reportMessage });\n\n throw err;\n});\n\nafterEach(() => {\n const reportMessage = Cypress.env(\"allure\").reportMessage;\n\n cy.task(\"allureReportTest\", reportMessage, { log: false });\n});\n"],
5
+ "mappings": ";AAEA,IAAM,oBAAoB,OACvB;AAAA,EACC,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,UAAU,CAAC;AACb;AAEF,IAAM,EAAE,kBAAkB,iBAAiB,gBAAgB,IAAI,MAAM,OAAO;AAE5E,IAAM,eAAe,CAAC,SAA+B;AACnD,QAAM,OAAiB,CAAC;AACxB,MAAI,eAAwC,KAAK;AAEjD,SAAO,cAAc;AACnB,QAAI,aAAa,OAAO;AACtB,WAAK,QAAQ,aAAa,KAAK;AAAA,IACjC;AAEA,mBAAe,aAAa;AAAA,EAC9B;AAEA,SAAO;AACT;AACA,IAAM,uBAAuB,CAAC,kBAC5B,cAAc,SAAS,OAAO,CAAC,KAAK,YAAY;AAC9C,MAAI,QAAQ,8CAAqC,QAAQ,wCAAiC;AACxF,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ,4CAAmC;AAC7C,QAAI,KAAK,CAAC,OAAO,CAAC;AAElB,WAAO;AAAA,EACT;AAEA,QAAM,oBAAoB,IAAI,cAAc,CAAC,SAAS,KAAK,WAAW,CAAC;AAEvE,MAAI,sBAAsB,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
3
+ export type CypressWrappedAttachment = {
4
+ type: string;
5
+ data: unknown;
6
+ };
7
+ export declare const uint8ArrayToBase64: (data: unknown) => string;
8
+ export declare const normalizeAttachmentContentEncoding: (data: unknown, encoding: BufferEncoding) => BufferEncoding;
9
+ export declare const label: (name: string, value: string) => void;
10
+ export declare const link: (url: string, name?: string, type?: string) => void;
11
+ export declare const parameter: (name: string, value: string, options?: ParameterOptions) => void;
12
+ export declare const description: (markdown: string) => void;
13
+ export declare const descriptionHtml: (html: string) => void;
14
+ export declare const testCaseId: (value: string) => void;
15
+ export declare const historyId: (value: string) => void;
16
+ export declare const allureId: (value: string) => void;
17
+ export declare const displayName: (name: string) => void;
18
+ export declare const issue: (url: string, name?: string) => void;
19
+ export declare const tms: (url: string, name?: string) => void;
20
+ export declare const epic: (name: string) => void;
21
+ export declare const feature: (name: string) => void;
22
+ export declare const story: (name: string) => void;
23
+ export declare const suite: (name: string) => void;
24
+ export declare const parentSuite: (name: string) => void;
25
+ export declare const subSuite: (name: string) => void;
26
+ export declare const owner: (name: string) => void;
27
+ export declare const severity: (name: string) => void;
28
+ export declare const layer: (name: string) => void;
29
+ export declare const tag: (name: string) => void;
30
+ export declare const attachment: (name: string, content: unknown, type?: string, encoding?: BufferEncoding) => void;
31
+ export declare const step: (name: string, body: () => void) => void;
package/dist/index.js ADDED
@@ -0,0 +1,216 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.ts
20
+ var src_exports = {};
21
+ __export(src_exports, {
22
+ allureId: () => allureId,
23
+ attachment: () => attachment,
24
+ description: () => description,
25
+ descriptionHtml: () => descriptionHtml,
26
+ displayName: () => displayName,
27
+ epic: () => epic,
28
+ feature: () => feature,
29
+ historyId: () => historyId,
30
+ issue: () => issue,
31
+ label: () => label,
32
+ layer: () => layer,
33
+ link: () => link,
34
+ normalizeAttachmentContentEncoding: () => normalizeAttachmentContentEncoding,
35
+ owner: () => owner,
36
+ parameter: () => parameter,
37
+ parentSuite: () => parentSuite,
38
+ severity: () => severity,
39
+ step: () => step,
40
+ story: () => story,
41
+ subSuite: () => subSuite,
42
+ suite: () => suite,
43
+ tag: () => tag,
44
+ testCaseId: () => testCaseId,
45
+ tms: () => tms,
46
+ uint8ArrayToBase64: () => uint8ArrayToBase64
47
+ });
48
+ module.exports = __toCommonJS(src_exports);
49
+
50
+ // src/utils.ts
51
+ var pushReportMessage = (message) => {
52
+ const reportMessage = Cypress.env("allure").reportMessage;
53
+ reportMessage.messages.push(message);
54
+ Cypress.env("allure", { reportMessage });
55
+ };
56
+
57
+ // src/index.ts
58
+ var uint8ArrayToBase64 = (data) => {
59
+ const u8arrayLike = Array.isArray(data) || data.buffer;
60
+ if (!u8arrayLike) {
61
+ return data;
62
+ }
63
+ return btoa(String.fromCharCode.apply(null, data));
64
+ };
65
+ var normalizeAttachmentContentEncoding = (data, encoding) => {
66
+ const u8arrayLike = Array.isArray(data) || data.buffer;
67
+ if (u8arrayLike) {
68
+ return "base64";
69
+ }
70
+ return encoding;
71
+ };
72
+ var label = (name, value) => {
73
+ pushReportMessage({
74
+ type: "METADATA" /* METADATA */,
75
+ payload: {
76
+ labels: [{ name, value }]
77
+ }
78
+ });
79
+ };
80
+ var link = (url, name, type) => {
81
+ pushReportMessage({
82
+ type: "METADATA" /* METADATA */,
83
+ payload: {
84
+ links: [{ type, url, name }]
85
+ }
86
+ });
87
+ };
88
+ var parameter = (name, value, options) => {
89
+ pushReportMessage({
90
+ type: "METADATA" /* METADATA */,
91
+ payload: {
92
+ parameter: [{ name, value, ...options }]
93
+ }
94
+ });
95
+ };
96
+ var description = (markdown) => {
97
+ pushReportMessage({
98
+ type: "METADATA" /* METADATA */,
99
+ payload: {
100
+ description: markdown
101
+ }
102
+ });
103
+ };
104
+ var descriptionHtml = (html) => {
105
+ pushReportMessage({
106
+ type: "METADATA" /* METADATA */,
107
+ payload: {
108
+ descriptionHtml: html
109
+ }
110
+ });
111
+ };
112
+ var testCaseId = (value) => {
113
+ pushReportMessage({
114
+ type: "METADATA" /* METADATA */,
115
+ payload: {
116
+ testCaseId: value
117
+ }
118
+ });
119
+ };
120
+ var historyId = (value) => {
121
+ pushReportMessage({
122
+ type: "METADATA" /* METADATA */,
123
+ payload: {
124
+ historyId: value
125
+ }
126
+ });
127
+ };
128
+ var allureId = (value) => {
129
+ pushReportMessage({
130
+ type: "METADATA" /* METADATA */,
131
+ payload: {
132
+ labels: [{ name: "ALLURE_ID" /* ALLURE_ID */, value }]
133
+ }
134
+ });
135
+ };
136
+ var displayName = (name) => {
137
+ pushReportMessage({
138
+ type: "METADATA" /* METADATA */,
139
+ payload: {
140
+ displayName: name
141
+ }
142
+ });
143
+ };
144
+ var issue = (url, name) => {
145
+ link(url, name, "issue" /* ISSUE */);
146
+ };
147
+ var tms = (url, name) => {
148
+ link(url, name, "tms" /* TMS */);
149
+ };
150
+ var epic = (name) => {
151
+ label("epic" /* EPIC */, name);
152
+ };
153
+ var feature = (name) => {
154
+ label("feature" /* FEATURE */, name);
155
+ };
156
+ var story = (name) => {
157
+ label("story" /* STORY */, name);
158
+ };
159
+ var suite = (name) => {
160
+ label("suite" /* SUITE */, name);
161
+ };
162
+ var parentSuite = (name) => {
163
+ label("parentSuite" /* PARENT_SUITE */, name);
164
+ };
165
+ var subSuite = (name) => {
166
+ label("subSuite" /* SUB_SUITE */, name);
167
+ };
168
+ var owner = (name) => {
169
+ label("owner" /* OWNER */, name);
170
+ };
171
+ var severity = (name) => {
172
+ label("severity" /* SEVERITY */, name);
173
+ };
174
+ var layer = (name) => {
175
+ label("layer" /* LAYER */, name);
176
+ };
177
+ var tag = (name) => {
178
+ label("tag" /* TAG */, name);
179
+ };
180
+ var attachment = (name, content, type = "text/plain", encoding = "utf8") => {
181
+ const attachmentRawContent = content?.type === "Buffer" ? content.data : content;
182
+ const actualEncoding = normalizeAttachmentContentEncoding(attachmentRawContent, encoding);
183
+ const attachmentContent = uint8ArrayToBase64(attachmentRawContent);
184
+ pushReportMessage({
185
+ type: "METADATA" /* METADATA */,
186
+ payload: {
187
+ attachments: [
188
+ {
189
+ content: attachmentContent,
190
+ encoding: actualEncoding,
191
+ name,
192
+ type
193
+ }
194
+ ]
195
+ }
196
+ });
197
+ };
198
+ var step = (name, body) => {
199
+ cy.wrap(null, { log: false }).then(() => {
200
+ pushReportMessage({
201
+ type: "STEP_STARTED" /* STEP_STARTED */,
202
+ payload: { name, start: Date.now() }
203
+ });
204
+ body();
205
+ }).then(() => {
206
+ pushReportMessage({
207
+ type: "STEP_ENDED" /* STEP_ENDED */,
208
+ payload: {
209
+ status: "passed" /* PASSED */,
210
+ stage: "finished" /* FINISHED */,
211
+ stop: Date.now()
212
+ }
213
+ });
214
+ });
215
+ };
216
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts", "../src/utils.ts"],
4
+ "sourcesContent": ["import { LabelName, LinkType, MessageType, type ParameterOptions, Stage, Status } from \"./model\";\nimport { pushReportMessage } from \"./utils\";\n\nexport type CypressWrappedAttachment = { type: string; data: unknown };\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));\n};\n\nexport const normalizeAttachmentContentEncoding = (data: unknown, encoding: BufferEncoding): BufferEncoding => {\n // @ts-ignore\n const u8arrayLike = Array.isArray(data) || data.buffer;\n\n if (u8arrayLike) {\n return \"base64\";\n }\n\n return encoding;\n};\n\nexport const label = (name: string, value: string) => {\n pushReportMessage({\n type: MessageType.METADATA,\n payload: {\n labels: [{ name, value }],\n },\n });\n};\nexport const link = (url: string, name?: string, type?: string) => {\n pushReportMessage({\n type: MessageType.METADATA,\n payload: {\n links: [{ type, url, name }],\n },\n });\n};\nexport const parameter = (name: string, value: string, options?: ParameterOptions) => {\n pushReportMessage({\n type: MessageType.METADATA,\n payload: {\n parameter: [{ name, value, ...options }],\n },\n });\n};\nexport const description = (markdown: string) => {\n pushReportMessage({\n type: MessageType.METADATA,\n payload: {\n description: markdown,\n },\n });\n};\nexport const descriptionHtml = (html: string) => {\n pushReportMessage({\n type: MessageType.METADATA,\n payload: {\n descriptionHtml: html,\n },\n });\n};\nexport const testCaseId = (value: string) => {\n pushReportMessage({\n type: MessageType.METADATA,\n payload: {\n testCaseId: value,\n },\n });\n};\nexport const historyId = (value: string) => {\n pushReportMessage({\n type: MessageType.METADATA,\n payload: {\n historyId: value,\n },\n });\n};\nexport const allureId = (value: string) => {\n pushReportMessage({\n type: MessageType.METADATA,\n payload: {\n labels: [{ name: LabelName.ALLURE_ID, value }],\n },\n });\n};\nexport const displayName = (name: string) => {\n pushReportMessage({\n type: MessageType.METADATA,\n payload: {\n displayName: name,\n },\n });\n};\nexport const issue = (url: string, name?: string) => {\n link(url, name, LinkType.ISSUE);\n};\nexport const tms = (url: string, name?: string) => {\n link(url, name, LinkType.TMS);\n};\nexport const epic = (name: string) => {\n label(LabelName.EPIC, name);\n};\nexport const feature = (name: string) => {\n label(LabelName.FEATURE, name);\n};\nexport const story = (name: string) => {\n label(LabelName.STORY, name);\n};\nexport const suite = (name: string) => {\n label(LabelName.SUITE, name);\n};\nexport const parentSuite = (name: string) => {\n label(LabelName.PARENT_SUITE, name);\n};\nexport const subSuite = (name: string) => {\n label(LabelName.SUB_SUITE, name);\n};\nexport const owner = (name: string) => {\n label(LabelName.OWNER, name);\n};\nexport const severity = (name: string) => {\n label(LabelName.SEVERITY, name);\n};\nexport const layer = (name: string) => {\n label(LabelName.LAYER, name);\n};\nexport const tag = (name: string) => {\n label(LabelName.TAG, name);\n};\nexport const attachment = (\n name: string,\n content: unknown,\n type: string = \"text/plain\",\n encoding: BufferEncoding = \"utf8\",\n) => {\n // @ts-ignore\n const attachmentRawContent: string | Uint8Array = content?.type === \"Buffer\" ? content.data : content;\n const actualEncoding = normalizeAttachmentContentEncoding(attachmentRawContent, encoding);\n const attachmentContent = uint8ArrayToBase64(attachmentRawContent);\n\n pushReportMessage({\n type: MessageType.METADATA,\n payload: {\n attachments: [\n {\n content: attachmentContent,\n encoding: actualEncoding,\n name,\n type,\n },\n ],\n },\n });\n};\nexport const step = (name: string, body: () => void) => {\n cy.wrap(null, { log: false })\n .then(() => {\n pushReportMessage({\n type: MessageType.STEP_STARTED,\n payload: { name, start: Date.now() },\n });\n\n body();\n })\n .then(() => {\n pushReportMessage({\n type: MessageType.STEP_ENDED,\n payload: {\n status: Status.PASSED,\n stage: Stage.FINISHED,\n stop: Date.now(),\n },\n });\n });\n};\n", "import { ReportFinalMessage, ReporterMessage, TestEndMessage, TestStartMessage } from \"./model\";\n\nexport const setStartTestReportMessage = (message: TestStartMessage) => {\n const reportMessage: ReportFinalMessage = Cypress.env(\"allure\").reportMessage;\n\n reportMessage.startMessage = message;\n\n Cypress.env(\"allure\", { reportMessage });\n};\n\nexport const setEndTestReportMessage = (message: TestEndMessage) => {\n const reportMessage: ReportFinalMessage = Cypress.env(\"allure\").reportMessage;\n\n reportMessage.endMessage = message;\n\n Cypress.env(\"allure\", { reportMessage });\n};\n\nexport const pushReportMessage = (message: ReporterMessage) => {\n const reportMessage: ReportFinalMess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