cypress-qase-reporter 2.0.1 → 2.0.3

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
@@ -2,8 +2,6 @@
2
2
 
3
3
  Publish results simple and easy.
4
4
 
5
- ## How to install
6
-
7
5
  To install the latest version, run:
8
6
 
9
7
  ```sh
package/changelog.md CHANGED
@@ -1,3 +1,19 @@
1
+ # cypress-qase-reporter@2.0.3
2
+
3
+ ## What's new
4
+
5
+ Cypress doesn't finish the process after the last test.
6
+ The reporter will wait for all results to be sent to Qase and will not block the process after sending.
7
+
8
+ # cypress-qase-reporter@2.0.2
9
+
10
+ ## What's new
11
+
12
+ 1. Cypress kills the process after the last tests.
13
+ The reporter will wait for all results to be sent to Qase and will not block the process after sending.
14
+
15
+ 2. The reporter will collect suites and add them to results.
16
+
1
17
  # cypress-qase-reporter@2.0.1
2
18
 
3
19
  ## What's new
@@ -0,0 +1 @@
1
+ declare function runChild(): Promise<void>;
package/dist/child.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ const runChild = async () => {
3
+ setTimeout(() => {
4
+ // do nothing
5
+ }, 10000);
6
+ };
7
+ runChild();
@@ -58,8 +58,15 @@ export declare class CypressQaseReporter extends reporters.Base {
58
58
  */
59
59
  private addTestResult;
60
60
  /**
61
+ * @param {Test} test
62
+ * @param {number[]} ids
63
+ * @private
64
+ */
65
+ private getSignature;
66
+ /**
67
+ * @param {Suite} suite
61
68
  * @private
62
69
  */
63
- private preventExit;
70
+ private getFile;
64
71
  }
65
72
  export {};
package/dist/reporter.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CypressQaseReporter = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const uuid_1 = require("uuid");
9
+ const child_process_1 = require("child_process");
9
10
  const mocha_1 = require("mocha");
10
11
  const qase_javascript_commons_1 = require("qase-javascript-commons");
11
12
  const traverse_dir_1 = require("./utils/traverse-dir");
@@ -82,11 +83,8 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
82
83
  runner.on(EVENT_RUN_BEGIN, () => this.reporter.startTestRun());
83
84
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
84
85
  runner.once(EVENT_RUN_END, async () => {
85
- this.preventExit();
86
86
  await this.reporter.publish();
87
- if (process.exitCode !== undefined) {
88
- process.exit(process.exitCode);
89
- }
87
+ (0, child_process_1.spawnSync)('node', [`${__dirname}/child.js`], { stdio: 'inherit' });
90
88
  });
91
89
  }
92
90
  /**
@@ -98,6 +96,21 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
98
96
  const attachments = this.screenshotsFolder
99
97
  ? CypressQaseReporter.findAttachments(ids, this.screenshotsFolder)
100
98
  : undefined;
99
+ let relations = {};
100
+ if (test.parent !== undefined) {
101
+ const data = [];
102
+ for (const suite of test.parent.titlePath()) {
103
+ data.push({
104
+ title: suite,
105
+ public_id: null,
106
+ });
107
+ }
108
+ relations = {
109
+ suite: {
110
+ data: data,
111
+ },
112
+ };
113
+ }
101
114
  const result = {
102
115
  attachments: attachments ?? [],
103
116
  author: null,
@@ -105,9 +118,9 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
105
118
  message: test.err?.message ?? null,
106
119
  muted: false,
107
120
  params: {},
108
- relations: {},
121
+ relations: relations,
109
122
  run_id: null,
110
- signature: '',
123
+ signature: this.getSignature(test, ids),
111
124
  steps: [],
112
125
  id: test.id,
113
126
  execution: {
@@ -122,21 +135,43 @@ class CypressQaseReporter extends mocha_1.reporters.Base {
122
135
  },
123
136
  testops_id: ids.length > 0 ? ids : null,
124
137
  title: test.title,
125
- // suiteTitle: test.parent?.titlePath(),
126
138
  };
127
139
  void this.reporter.addTestResult(result);
128
140
  }
129
141
  /**
142
+ * @param {Test} test
143
+ * @param {number[]} ids
130
144
  * @private
131
145
  */
132
- preventExit() {
133
- // eslint-disable-next-line @typescript-eslint/unbound-method
134
- const _exit = process.exit;
135
- const mutableProcess = process;
136
- mutableProcess.exit = (code) => {
137
- process.exitCode = code || 0;
138
- process.exit = _exit;
139
- };
146
+ getSignature(test, ids) {
147
+ let signature = '';
148
+ const file = test.parent ? this.getFile(test.parent) : undefined;
149
+ if (file) {
150
+ signature = file.split('/').join('::');
151
+ }
152
+ if (test.parent) {
153
+ for (const suite of test.parent.titlePath()) {
154
+ signature += '::' + suite.toLowerCase().replace(/\s/g, '_');
155
+ }
156
+ }
157
+ signature += '::' + test.title.toLowerCase().replace(/\s/g, '_');
158
+ if (ids.length > 0) {
159
+ signature += '::' + ids.join('::');
160
+ }
161
+ return signature;
162
+ }
163
+ /**
164
+ * @param {Suite} suite
165
+ * @private
166
+ */
167
+ getFile(suite) {
168
+ if (suite.file) {
169
+ return suite.file;
170
+ }
171
+ if (suite.parent) {
172
+ return this.getFile(suite.parent);
173
+ }
174
+ return undefined;
140
175
  }
141
176
  }
142
177
  exports.CypressQaseReporter = CypressQaseReporter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress-qase-reporter",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Qase Cypress Reporter",
5
5
  "homepage": "https://github.com/qase-tms/qase-javascript",
6
6
  "sideEffects": false,
@@ -5,5 +5,5 @@
5
5
  "noEmit": false
6
6
  },
7
7
 
8
- "include": ["./src/**/*.ts"]
8
+ "include": ["./src/**/*.ts", "./src/*.js"],
9
9
  }