testit-adapter-mocha 3.7.7 → 3.7.8
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 +1 -1
- package/lib/reporter.js +28 -43
- package/lib/utils.js +1 -2
- package/package.json +2 -2
package/README.md
CHANGED
package/lib/reporter.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -40,7 +31,6 @@ const StateConstants = {
|
|
|
40
31
|
};
|
|
41
32
|
class TmsReporter extends Reporter {
|
|
42
33
|
constructor(runner, options) {
|
|
43
|
-
var _a;
|
|
44
34
|
super(runner, options);
|
|
45
35
|
this.attachmentsQueue = [];
|
|
46
36
|
this.autotestsQueue = [];
|
|
@@ -67,8 +57,7 @@ class TmsReporter extends Reporter {
|
|
|
67
57
|
? this.additions.addAttachments(pathsOrContent, fileName)
|
|
68
58
|
: this.additions.addAttachments(pathsOrContent);
|
|
69
59
|
promise.then((attachments) => {
|
|
70
|
-
|
|
71
|
-
(_a = target.attachments) === null || _a === void 0 ? void 0 : _a.push(...attachments);
|
|
60
|
+
target.attachments?.push(...attachments);
|
|
72
61
|
});
|
|
73
62
|
this.attachmentsQueue.push(promise);
|
|
74
63
|
return promise;
|
|
@@ -80,13 +69,12 @@ class TmsReporter extends Reporter {
|
|
|
80
69
|
this.additions.addMessage(message);
|
|
81
70
|
};
|
|
82
71
|
this.addSteps = (title, stepConstructor) => {
|
|
83
|
-
var _a;
|
|
84
72
|
const start = new Date();
|
|
85
73
|
const prevType = this.currentType;
|
|
86
74
|
this.currentType = "step";
|
|
87
75
|
const step = new step_1.TestStep(title);
|
|
88
76
|
try {
|
|
89
|
-
stepConstructor
|
|
77
|
+
stepConstructor?.(step);
|
|
90
78
|
this.currentStep.outcome = "Passed";
|
|
91
79
|
}
|
|
92
80
|
catch (err) {
|
|
@@ -100,31 +88,29 @@ class TmsReporter extends Reporter {
|
|
|
100
88
|
this.currentStep.startedOn = start;
|
|
101
89
|
this.currentStep.completedOn = new Date();
|
|
102
90
|
this.currentStep.duration = Date.now() - start.getTime();
|
|
103
|
-
|
|
91
|
+
this.currentTest.stepResults?.push(this.currentStep);
|
|
104
92
|
this.currentType = prevType;
|
|
105
93
|
this.currentStep = emptyStep();
|
|
106
94
|
};
|
|
107
|
-
const config = new testit_js_commons_1.ConfigComposer().compose(options
|
|
95
|
+
const config = new testit_js_commons_1.ConfigComposer().compose(options?.tmsOptions);
|
|
108
96
|
this.strategy = testit_js_commons_1.StrategyFactory.create(config);
|
|
109
97
|
this.additions = new testit_js_commons_1.Additions(config);
|
|
110
98
|
if (options.parallel) {
|
|
111
|
-
options.require = [...(
|
|
99
|
+
options.require = [...(options.require ?? []), (0, utils_1.resolveParallelModeSetupFile)()];
|
|
112
100
|
}
|
|
113
101
|
else {
|
|
114
102
|
this.applyListeners();
|
|
115
103
|
}
|
|
116
104
|
}
|
|
117
|
-
teardown() {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
console.log("Error load test run. \n", err.body);
|
|
125
|
-
});
|
|
126
|
-
yield this.strategy.teardown();
|
|
105
|
+
async teardown() {
|
|
106
|
+
await Promise.all(this.attachmentsQueue).catch((err) => {
|
|
107
|
+
console.log("Error loading attachments. \n", err.body);
|
|
108
|
+
});
|
|
109
|
+
await Promise.all(this.autotestsQueue);
|
|
110
|
+
await this.strategy.loadTestRun(this.autotestsForTestRun).catch((err) => {
|
|
111
|
+
console.log("Error load test run. \n", err.body);
|
|
127
112
|
});
|
|
113
|
+
await this.strategy.teardown();
|
|
128
114
|
}
|
|
129
115
|
clearContext(ctx) {
|
|
130
116
|
ctx.externalId = undefined;
|
|
@@ -152,24 +138,23 @@ class TmsReporter extends Reporter {
|
|
|
152
138
|
this.currentTest.startedOn = new Date();
|
|
153
139
|
}
|
|
154
140
|
onEndTest(test) {
|
|
155
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
156
141
|
const hooks = (0, utils_1.extractHooks)(test.parent);
|
|
157
142
|
const setup = [...hooks.beforeAll, ...hooks.beforeEach];
|
|
158
143
|
const teardown = [...hooks.afterEach, ...hooks.afterAll];
|
|
159
144
|
const autotestPost = {
|
|
160
|
-
externalId:
|
|
161
|
-
name:
|
|
162
|
-
description:
|
|
163
|
-
title:
|
|
164
|
-
links:
|
|
165
|
-
labels:
|
|
166
|
-
tags:
|
|
167
|
-
namespace:
|
|
168
|
-
classname:
|
|
145
|
+
externalId: test.ctx?.externalId ?? testit_js_commons_1.Utils.getHash(test.title),
|
|
146
|
+
name: test.ctx?.displayName ?? test.title,
|
|
147
|
+
description: test.ctx?.description,
|
|
148
|
+
title: test.ctx?.title,
|
|
149
|
+
links: test.ctx?.links,
|
|
150
|
+
labels: test.ctx?.labels?.map((label) => ({ name: label })),
|
|
151
|
+
tags: test.ctx?.tags,
|
|
152
|
+
namespace: test.ctx?.namespace ?? this._getNameSpace(test.file),
|
|
153
|
+
classname: test.ctx?.classname ?? this._getClassName(test.file),
|
|
169
154
|
steps: this.currentTest.stepResults,
|
|
170
155
|
setup,
|
|
171
156
|
teardown,
|
|
172
|
-
workItemIds:
|
|
157
|
+
workItemIds: test.ctx?.workItemsIds,
|
|
173
158
|
externalKey: test.title,
|
|
174
159
|
};
|
|
175
160
|
const promise = this.strategy.loadAutotest(autotestPost, this._getOutcome(test.state));
|
|
@@ -185,12 +170,12 @@ class TmsReporter extends Reporter {
|
|
|
185
170
|
teardownResults: teardown,
|
|
186
171
|
attachments: this.currentTest.attachments,
|
|
187
172
|
links: this.additions.links,
|
|
188
|
-
message:
|
|
173
|
+
message: test.err?.message
|
|
189
174
|
? this.additions.messages.concat(test.err.message).join("\n")
|
|
190
175
|
: this.additions.messages.join("\n"),
|
|
191
|
-
traces:
|
|
192
|
-
parameters:
|
|
193
|
-
properties:
|
|
176
|
+
traces: test.err?.stack,
|
|
177
|
+
parameters: test.ctx?.parameters,
|
|
178
|
+
properties: test.ctx?.properties,
|
|
194
179
|
});
|
|
195
180
|
this.resetTest(test);
|
|
196
181
|
}
|
|
@@ -217,7 +202,7 @@ class TmsReporter extends Reporter {
|
|
|
217
202
|
}
|
|
218
203
|
}
|
|
219
204
|
_getDuration(duration) {
|
|
220
|
-
return
|
|
205
|
+
return duration ?? this.currentTest.startedOn
|
|
221
206
|
? Date.now() - this.currentTest.startedOn.getTime()
|
|
222
207
|
: 0;
|
|
223
208
|
}
|
package/lib/utils.js
CHANGED
|
@@ -5,10 +5,9 @@ exports.hookToStep = hookToStep;
|
|
|
5
5
|
exports.extractHooks = extractHooks;
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
function hookToStep(hook) {
|
|
8
|
-
var _a;
|
|
9
8
|
return {
|
|
10
9
|
title: hook.title,
|
|
11
|
-
duration:
|
|
10
|
+
duration: hook.duration ?? 0,
|
|
12
11
|
};
|
|
13
12
|
}
|
|
14
13
|
function extractHooks(suite) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testit-adapter-mocha",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.8",
|
|
4
4
|
"description": "Mocha adapter for Test IT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/types.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"mocha": "^10.2.0",
|
|
33
33
|
"deasync-promise": "^1.0.1",
|
|
34
|
-
"testit-js-commons": "3.7.
|
|
34
|
+
"testit-js-commons": "3.7.8"
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
37
|
"lib"
|