newman-reporter-qase 2.1.5 → 2.2.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/changelog.md CHANGED
@@ -1,3 +1,9 @@
1
+ # qase-newman@2.2.0
2
+
3
+ ## What's new
4
+
5
+ - Added support for multi-project support.
6
+
1
7
  # qase-newman@2.1.5
2
8
 
3
9
  ## What's new
@@ -1,8 +1,7 @@
1
- /// <reference types="node" />
2
1
  import { EventEmitter } from 'events';
3
2
  import { NewmanRunOptions } from 'newman';
4
3
  import { EventList, Item, PropertyBase, PropertyBaseDefinition } from 'postman-collection';
5
- import { ConfigType, ConfigLoader } from 'qase-javascript-commons';
4
+ import { ConfigType, TestopsProjectMapping, ConfigLoader } from 'qase-javascript-commons';
6
5
  export type NewmanQaseOptionsType = ConfigType;
7
6
  /**
8
7
  * @class NewmanQaseReporter
@@ -16,6 +15,14 @@ export declare class NewmanQaseReporter {
16
15
  * @type {RegExp}
17
16
  */
18
17
  static qaseParamRegExp: RegExp;
18
+ /** Matches // qase PROJ1: 1,2 or // qase PROJ2: 3 for multi-project. */
19
+ static qaseProjectRegExp: RegExp;
20
+ /**
21
+ * Parse multi-project mapping from test script comments (e.g. // qase PROJ1: 1,2).
22
+ * @param {EventList} eventList
23
+ * @returns {TestopsProjectMapping}
24
+ */
25
+ static getProjectMapping(eventList: EventList): TestopsProjectMapping;
19
26
  /**
20
27
  * @param {EventList} eventList
21
28
  * @returns {number[]}
package/dist/reporter.js CHANGED
@@ -19,6 +19,34 @@ class NewmanQaseReporter {
19
19
  * @type {RegExp}
20
20
  */
21
21
  static qaseParamRegExp = /qase\.parameters:\s*([\w.]+(?:\s*,\s*[\w.]+)*)/i;
22
+ /** Matches // qase PROJ1: 1,2 or // qase PROJ2: 3 for multi-project. */
23
+ static qaseProjectRegExp = /\/\/\s*[qQ]ase\s+([A-Za-z0-9_]+):\s*([\d,\s]+)/g;
24
+ /**
25
+ * Parse multi-project mapping from test script comments (e.g. // qase PROJ1: 1,2).
26
+ * @param {EventList} eventList
27
+ * @returns {TestopsProjectMapping}
28
+ */
29
+ static getProjectMapping(eventList) {
30
+ const projectMapping = {};
31
+ eventList.each((event) => {
32
+ if (event.listen === 'test' && event.script.exec) {
33
+ event.script.exec.forEach((line) => {
34
+ let m;
35
+ const re = new RegExp(NewmanQaseReporter.qaseProjectRegExp.source, 'gi');
36
+ while ((m = re.exec(line)) !== null) {
37
+ const projectCode = m[1]?.trim();
38
+ const idsStr = (m[2] ?? '').replace(/\s/g, '');
39
+ const ids = idsStr.split(',').map((s) => parseInt(s, 10)).filter((n) => !Number.isNaN(n));
40
+ if (projectCode && projectCode.toUpperCase() !== 'ID' && ids.length > 0) {
41
+ const existing = projectMapping[projectCode] ?? [];
42
+ projectMapping[projectCode] = [...existing, ...ids];
43
+ }
44
+ }
45
+ });
46
+ }
47
+ });
48
+ return projectMapping;
49
+ }
22
50
  /**
23
51
  * @param {EventList} eventList
24
52
  * @returns {number[]}
@@ -145,7 +173,8 @@ class NewmanQaseReporter {
145
173
  };
146
174
  }
147
175
  const ids = NewmanQaseReporter.getCaseIds(item.events);
148
- this.pendingResultMap.set(item.id, {
176
+ const projectMapping = NewmanQaseReporter.getProjectMapping(item.events);
177
+ const pendingResult = {
149
178
  attachments: [],
150
179
  author: null,
151
180
  execution: {
@@ -168,7 +197,9 @@ class NewmanQaseReporter {
168
197
  testops_id: ids.length > 0 ? ids : null,
169
198
  id: item.id,
170
199
  title: item.name,
171
- });
200
+ testops_project_mapping: Object.keys(projectMapping).length > 0 ? projectMapping : null,
201
+ };
202
+ this.pendingResultMap.set(item.id, pendingResult);
172
203
  this.timerMap.set(item.id, Date.now());
173
204
  });
174
205
  runner.on('assertion', (err, exec) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newman-reporter-qase",
3
- "version": "2.1.5",
3
+ "version": "2.2.0",
4
4
  "description": "Qase TMS Newman Reporter",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -39,18 +39,18 @@
39
39
  "author": "Qase Team <support@qase.io>",
40
40
  "license": "Apache-2.0",
41
41
  "dependencies": {
42
- "qase-javascript-commons": "~2.4.2",
43
- "semver": "^7.5.1"
42
+ "qase-javascript-commons": "~2.5.0",
43
+ "semver": "^7.7.3"
44
44
  },
45
45
  "devDependencies": {
46
- "@jest/globals": "^29.5.0",
47
- "@types/jest": "^29.5.2",
46
+ "@jest/globals": "^29.7.0",
47
+ "@types/jest": "^29.5.14",
48
48
  "@types/newman": "^5.3.6",
49
- "@types/postman-collection": "^3.5.7",
49
+ "@types/postman-collection": "^3.5.11",
50
50
  "ajv": "^8.17.1",
51
- "jest": "^29.5.0",
52
- "postman-collection": "^4.1.7",
53
- "ts-jest": "^29.1.0"
51
+ "jest": "^29.7.0",
52
+ "postman-collection": "^4.5.0",
53
+ "ts-jest": "^29.4.5"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "newman": ">=5.3.0"
@@ -2,7 +2,9 @@
2
2
  "extends": "./tsconfig.json",
3
3
 
4
4
  "compilerOptions": {
5
- "noEmit": false
5
+ "noEmit": false,
6
+ "skipLibCheck": true,
7
+ "types": []
6
8
  },
7
9
 
8
10
  "include": ["./src/**/*.ts"]