newman-reporter-qase 2.0.0-beta.1 → 2.0.0-beta.2

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
@@ -1,11 +1,12 @@
1
- > # Qase TMS Newman reporter
2
- >
3
- > Publish results simple and easy.
1
+ # Qase TMS Newman reporter
4
2
 
5
- ## How to integrate
3
+ Publish results simple and easy.
4
+
5
+ The Newman reporter is currently in the closed beta stage.
6
+ To install the latest beta version, run:
6
7
 
7
8
  ```bash
8
- npm install newman-reporter-qase
9
+ npm install newman-reporter-qase@beta
9
10
  ```
10
11
 
11
12
  ## Example of usage
package/changelog.md ADDED
@@ -0,0 +1,11 @@
1
+ # qase-newman@2.0.0-beta.2
2
+
3
+ ## What's new
4
+
5
+ Add support for suites in test results.
6
+
7
+ # qase-newman@2.0.0-beta.1
8
+
9
+ ## What's new
10
+
11
+ First major beta release for the version 2 series of the Qase Newman reporter.
package/dist/reporter.js CHANGED
@@ -35,14 +35,15 @@ class NewmanQaseReporter {
35
35
  * @returns {string[]}
36
36
  * @private
37
37
  */
38
- static getParentTitles(item, titles = []) {
39
- const parent = item.parent();
40
- if (parent) {
41
- NewmanQaseReporter.getParentTitles(parent, titles);
42
- }
38
+ static getParentTitles(item) {
39
+ const titles = [];
43
40
  if ('name' in item) {
44
41
  titles.push(String(item.name));
45
42
  }
43
+ const parent = item.parent();
44
+ if (parent) {
45
+ titles.concat(NewmanQaseReporter.getParentTitles(parent));
46
+ }
46
47
  return titles;
47
48
  }
48
49
  /**
@@ -63,7 +64,7 @@ class NewmanQaseReporter {
63
64
  */
64
65
  this.timerMap = new Map();
65
66
  const config = configLoader.load();
66
- this.reporter = new qase_javascript_commons_1.QaseReporter({
67
+ this.reporter = qase_javascript_commons_1.QaseReporter.getInstance({
67
68
  ...(0, qase_javascript_commons_1.composeOptions)(options, config),
68
69
  frameworkPackage: 'newman',
69
70
  frameworkName: 'newman',
@@ -76,16 +77,50 @@ class NewmanQaseReporter {
76
77
  * @private
77
78
  */
78
79
  addRunnerListeners(runner) {
80
+ runner.on('start', () => {
81
+ this.reporter.startTestRun();
82
+ });
79
83
  runner.on('beforeItem', (_err, exec) => {
80
84
  const { item } = exec;
81
85
  const parent = item.parent();
86
+ const suites = parent ? NewmanQaseReporter.getParentTitles(parent) : [];
87
+ let relation = null;
88
+ if (suites.length > 0) {
89
+ const data = suites.map(title => {
90
+ return {
91
+ title: title,
92
+ public_id: null,
93
+ };
94
+ });
95
+ relation = {
96
+ suite: {
97
+ data: data,
98
+ },
99
+ };
100
+ }
101
+ const ids = NewmanQaseReporter.getCaseIds(item.events);
82
102
  this.pendingResultMap.set(item.id, {
103
+ attachments: [],
104
+ author: null,
105
+ execution: {
106
+ status: qase_javascript_commons_1.TestStatusEnum.passed,
107
+ start_time: 0,
108
+ end_time: 0,
109
+ duration: 0,
110
+ stacktrace: null,
111
+ thread: null,
112
+ },
113
+ fields: {},
114
+ message: null,
115
+ muted: false,
116
+ params: {},
117
+ relations: relation,
118
+ run_id: null,
119
+ signature: '',
120
+ steps: [],
121
+ testops_id: ids.length > 0 ? ids : null,
83
122
  id: item.id,
84
- testOpsId: NewmanQaseReporter.getCaseIds(item.events),
85
123
  title: item.name,
86
- suiteTitle: parent ? NewmanQaseReporter.getParentTitles(parent) : [],
87
- status: qase_javascript_commons_1.TestStatusEnum.passed,
88
- duration: 0,
89
124
  });
90
125
  this.timerMap.set(item.id, Date.now());
91
126
  });
@@ -93,8 +128,9 @@ class NewmanQaseReporter {
93
128
  const { item } = exec;
94
129
  const pendingResult = this.pendingResultMap.get(item.id);
95
130
  if (pendingResult && err) {
96
- pendingResult.status = qase_javascript_commons_1.TestStatusEnum.failed;
97
- pendingResult.error = err;
131
+ pendingResult.execution.status = qase_javascript_commons_1.TestStatusEnum.failed;
132
+ pendingResult.execution.stacktrace = err.stack ?? null;
133
+ pendingResult.message = err.message;
98
134
  }
99
135
  });
100
136
  runner.on('item', (_err, exec) => {
@@ -104,11 +140,9 @@ class NewmanQaseReporter {
104
140
  const timer = this.timerMap.get(item.id);
105
141
  if (timer) {
106
142
  const now = Date.now();
107
- pendingResult.startTime = timer;
108
- pendingResult.duration = now - timer;
109
- pendingResult.endTime = now;
143
+ pendingResult.execution.duration = now - timer;
110
144
  }
111
- this.reporter.addTestResult(pendingResult);
145
+ void this.reporter.addTestResult(pendingResult);
112
146
  }
113
147
  });
114
148
  runner.on('beforeDone', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newman-reporter-qase",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "Qase TMS Newman Reporter",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  "author": "Parviz Khavari <havaripa@gmail.com>",
40
40
  "license": "Apache-2.0",
41
41
  "dependencies": {
42
- "qase-javascript-commons": "^2.0.0-beta.1",
42
+ "qase-javascript-commons": "^2.0.8",
43
43
  "semver": "^7.5.1"
44
44
  },
45
45
  "devDependencies": {