newman-reporter-allure 2.0.0-beta.21 → 2.0.0-beta.23
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 +2 -2
- package/package.json +10 -3
- package/jest.config.js +0 -3
- package/report-preview.png +0 -0
- package/src/helpers.ts +0 -36
- package/src/index.ts +0 -495
- package/testops-preview.png +0 -0
- package/tests/helpers/runNewman.ts +0 -19
- package/tests/mocks/handlers.ts +0 -7
- package/tests/mocks/server.ts +0 -4
- package/tests/overview.test.ts +0 -105
- package/tsconfig.json +0 -14
package/README.md
CHANGED
|
@@ -100,10 +100,10 @@ Generate the static report web-application folder using allure-commandline
|
|
|
100
100
|
|
|
101
101
|
Report will be generated under folder "allure-report" in the root location.
|
|
102
102
|
|
|
103
|
-

|
|
104
104
|
|
|
105
105
|
## Allure TestOps preview
|
|
106
106
|
|
|
107
107
|
Generated report can be uploaded to Allure TestOps to store and analyze your tests-results.
|
|
108
108
|
|
|
109
|
-

|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newman-reporter-allure",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.23",
|
|
4
4
|
"description": "Allure Newman integration",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
7
10
|
"scripts": {
|
|
8
11
|
"clean": "rimraf ./dist ./out",
|
|
9
12
|
"compile": "tsc",
|
|
@@ -20,11 +23,15 @@
|
|
|
20
23
|
"postman",
|
|
21
24
|
"tests"
|
|
22
25
|
],
|
|
23
|
-
"repository":
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/allure-framework/allure-js.git",
|
|
29
|
+
"directory": "packages/newman-reporter-allure"
|
|
30
|
+
},
|
|
24
31
|
"author": "Virender",
|
|
25
32
|
"license": "Apache-2.0",
|
|
26
33
|
"dependencies": {
|
|
27
|
-
"allure-js-commons": "2.0.0-beta.
|
|
34
|
+
"allure-js-commons": "2.0.0-beta.23"
|
|
28
35
|
},
|
|
29
36
|
"devDependencies": {
|
|
30
37
|
"@types/newman": "^5.3.1",
|
package/jest.config.js
DELETED
package/report-preview.png
DELETED
|
Binary file
|
package/src/helpers.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Label, LabelName } from "allure-js-commons";
|
|
2
|
-
import { EventList } from "postman-collection";
|
|
3
|
-
|
|
4
|
-
export const extractMeta = (eventList: EventList) => {
|
|
5
|
-
const labels: Label[] = [];
|
|
6
|
-
|
|
7
|
-
const allureIdRegexp = /^@?allure.id[:=](?<id>.+)$/;
|
|
8
|
-
const allureLabelRegexp = /@?allure.label.(?<name>.+)[:=](?<value>.+)/;
|
|
9
|
-
|
|
10
|
-
eventList.each((event) => {
|
|
11
|
-
if (event.listen === "test" && event.script.exec) {
|
|
12
|
-
event.script.exec.forEach((line) => {
|
|
13
|
-
const isCommentLine = line.trim().startsWith("//");
|
|
14
|
-
if (!isCommentLine) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const trimmedCommentValue = line.trim().replace("//", "").trim();
|
|
18
|
-
|
|
19
|
-
const idMatch = trimmedCommentValue.match(allureIdRegexp);
|
|
20
|
-
const idValue = idMatch?.groups?.id;
|
|
21
|
-
if (idValue) {
|
|
22
|
-
labels.push({ name: LabelName.AS_ID, value: idValue });
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const labelMatch = trimmedCommentValue.match(allureLabelRegexp);
|
|
26
|
-
const { name, value } = labelMatch?.groups || {};
|
|
27
|
-
|
|
28
|
-
if (name && value) {
|
|
29
|
-
labels.push({ name, value });
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
return { labels };
|
|
36
|
-
};
|
package/src/index.ts
DELETED
|
@@ -1,495 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/unbound-method */
|
|
2
|
-
import type { EventEmitter } from "events";
|
|
3
|
-
import {
|
|
4
|
-
AllureGroup,
|
|
5
|
-
AllureRuntime,
|
|
6
|
-
AllureStep,
|
|
7
|
-
AllureTest,
|
|
8
|
-
ContentType,
|
|
9
|
-
InMemoryAllureWriter,
|
|
10
|
-
LabelName,
|
|
11
|
-
md5,
|
|
12
|
-
Stage,
|
|
13
|
-
Status,
|
|
14
|
-
StatusDetails,
|
|
15
|
-
} from "allure-js-commons";
|
|
16
|
-
import type { ConsoleEvent, Cursor, NewmanRunExecutionAssertion, NewmanRunOptions } from "newman";
|
|
17
|
-
import type {
|
|
18
|
-
Collection,
|
|
19
|
-
CollectionDefinition,
|
|
20
|
-
Event,
|
|
21
|
-
Item,
|
|
22
|
-
Request,
|
|
23
|
-
RequestBody,
|
|
24
|
-
Response,
|
|
25
|
-
} from "postman-collection";
|
|
26
|
-
import { extractMeta } from "./helpers";
|
|
27
|
-
|
|
28
|
-
interface AllureOptions {
|
|
29
|
-
export: string;
|
|
30
|
-
postProcessorForTest?: any;
|
|
31
|
-
collectionAsParentSuite?: boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface PmItem {
|
|
35
|
-
name: string;
|
|
36
|
-
passed: boolean;
|
|
37
|
-
failedAssertions: string[];
|
|
38
|
-
consoleLogs: string[];
|
|
39
|
-
requestData?: PmRequestData;
|
|
40
|
-
responseData?: PmResponseData;
|
|
41
|
-
prerequest?: string;
|
|
42
|
-
testScript?: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
interface PmRequestData {
|
|
46
|
-
url: string;
|
|
47
|
-
method: string;
|
|
48
|
-
body?: RequestBody;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
interface PmResponseData {
|
|
52
|
-
status: string;
|
|
53
|
-
code: number;
|
|
54
|
-
body: string;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
interface RunningItem {
|
|
58
|
-
name: string;
|
|
59
|
-
allureTest: AllureTest;
|
|
60
|
-
pmItem: PmItem;
|
|
61
|
-
steps: AllureStep[];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
class AllureReporter {
|
|
65
|
-
suites: AllureGroup[] = [];
|
|
66
|
-
runningItems: RunningItem[] = [];
|
|
67
|
-
currentNMGroup: Collection;
|
|
68
|
-
allureRuntime: AllureRuntime;
|
|
69
|
-
reporterOptions: AllureOptions;
|
|
70
|
-
options: {
|
|
71
|
-
collection: CollectionDefinition;
|
|
72
|
-
};
|
|
73
|
-
allureWriter?: InMemoryAllureWriter;
|
|
74
|
-
|
|
75
|
-
constructor(
|
|
76
|
-
emitter: EventEmitter,
|
|
77
|
-
reporterOptions: AllureOptions,
|
|
78
|
-
options: {
|
|
79
|
-
collection: CollectionDefinition;
|
|
80
|
-
},
|
|
81
|
-
) {
|
|
82
|
-
this.currentNMGroup = options.collection as Collection;
|
|
83
|
-
this.allureWriter = reporterOptions.postProcessorForTest
|
|
84
|
-
? new InMemoryAllureWriter()
|
|
85
|
-
: undefined;
|
|
86
|
-
|
|
87
|
-
this.allureRuntime = new AllureRuntime({
|
|
88
|
-
resultsDir: reporterOptions.export || "allure-results",
|
|
89
|
-
writer: this.allureWriter,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
this.reporterOptions = reporterOptions;
|
|
93
|
-
this.options = options;
|
|
94
|
-
|
|
95
|
-
this.registerEvents(emitter);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
get currentSuite() {
|
|
99
|
-
const lastIndex = this.suites.length - 1;
|
|
100
|
-
if (lastIndex >= 0) {
|
|
101
|
-
return this.suites[lastIndex];
|
|
102
|
-
} else {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
get currentStep() {
|
|
108
|
-
const lastIndex = (this.currentRunningItem?.steps?.length || 0) - 1;
|
|
109
|
-
if (lastIndex >= 0) {
|
|
110
|
-
return this.currentRunningItem?.steps[lastIndex];
|
|
111
|
-
} else {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
get currentRunningItem() {
|
|
117
|
-
const lastIndex = this.runningItems.length - 1;
|
|
118
|
-
|
|
119
|
-
if (lastIndex >= 0) {
|
|
120
|
-
return this.runningItems[lastIndex];
|
|
121
|
-
} else {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
get currentExecutable() {
|
|
127
|
-
const executable = this.currentTest;
|
|
128
|
-
if (!executable) {
|
|
129
|
-
throw new Error("No executable!");
|
|
130
|
-
}
|
|
131
|
-
return executable;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
get currentTest() {
|
|
135
|
-
const currentItem = this.currentRunningItem;
|
|
136
|
-
if (!currentItem) {
|
|
137
|
-
throw new Error("No active test");
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return currentItem.allureTest;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
set currentTest(allureTest) {
|
|
144
|
-
if (!this.currentRunningItem) {
|
|
145
|
-
throw new Error("Cannot find current test");
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
this.currentRunningItem.allureTest = allureTest;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
pathToItem(item: Item): string[] {
|
|
152
|
-
if (
|
|
153
|
-
!item ||
|
|
154
|
-
!(typeof item.parent === "function") ||
|
|
155
|
-
!(typeof item.forEachParent === "function")
|
|
156
|
-
) {
|
|
157
|
-
return [];
|
|
158
|
-
}
|
|
159
|
-
const chain: string[] = [];
|
|
160
|
-
|
|
161
|
-
if (this.options.collection.name && this.reporterOptions.collectionAsParentSuite) {
|
|
162
|
-
chain.push(this.options.collection.name);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
item.forEachParent((parent) => {
|
|
166
|
-
chain.unshift(parent.name || parent.id);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
return chain;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
getFullName(item: Item): string {
|
|
173
|
-
const chain = this.pathToItem(item);
|
|
174
|
-
return `${chain.join("/")}#${item.name}`;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
attachString(name: string, value: string | string[]) {
|
|
178
|
-
const stringToAttach = Array.isArray(value) ? value.join("\n") : value;
|
|
179
|
-
|
|
180
|
-
if (stringToAttach) {
|
|
181
|
-
const buf = Buffer.from(stringToAttach, "utf8");
|
|
182
|
-
const file = this.allureRuntime.writeAttachment(buf, ContentType.TEXT);
|
|
183
|
-
this.currentTest.addAttachment(name, ContentType.TEXT, file);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
setDescriptionHtml(html: string) {
|
|
188
|
-
if (html) {
|
|
189
|
-
this.currentExecutable.descriptionHtml = html;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
endTest(allureTest: AllureTest, status: Status, details?: StatusDetails) {
|
|
194
|
-
if (details) {
|
|
195
|
-
allureTest.statusDetails = details;
|
|
196
|
-
}
|
|
197
|
-
allureTest.status = status;
|
|
198
|
-
allureTest.stage = Stage.FINISHED;
|
|
199
|
-
allureTest.endTest();
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
startStep(name: string) {
|
|
203
|
-
const allureStep = this.currentExecutable.startStep(name);
|
|
204
|
-
this.currentRunningItem?.steps.push(allureStep);
|
|
205
|
-
return allureStep;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
endStep(status: Status) {
|
|
209
|
-
const step = this.currentRunningItem?.steps.pop();
|
|
210
|
-
if (!step) {
|
|
211
|
-
throw new Error("Step not found");
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
step.status = status;
|
|
215
|
-
step.endStep();
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
escape(val: string) {
|
|
219
|
-
return (
|
|
220
|
-
val
|
|
221
|
-
.replace("\n", "")
|
|
222
|
-
.replace("\r", "")
|
|
223
|
-
// eslint-disable-next-line @typescript-eslint/quotes
|
|
224
|
-
.replace('"', '"')
|
|
225
|
-
.replace(/[\u0100-\uffff]/g, (c) => `|0x${c.charCodeAt(0).toString(16).padStart(4, "0")}`)
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
registerEvents(emitter: EventEmitter) {
|
|
230
|
-
emitter.on("start", this.onStart.bind(this));
|
|
231
|
-
emitter.on("beforeItem", this.onBeforeItem.bind(this));
|
|
232
|
-
emitter.on("item", this.onItem.bind(this));
|
|
233
|
-
emitter.on("prerequest", this.onPrerequest.bind(this));
|
|
234
|
-
emitter.on("request", this.onRequest.bind(this));
|
|
235
|
-
emitter.on("test", this.onTest.bind(this));
|
|
236
|
-
emitter.on("assertion", this.onAssertion.bind(this));
|
|
237
|
-
emitter.on("console", this.onConsole.bind(this));
|
|
238
|
-
emitter.on("done", this.onDone.bind(this));
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
onStart(_err: any, _args: any) {
|
|
242
|
-
const suiteName = (this.options.collection as Collection).name;
|
|
243
|
-
const scope = this.currentSuite || this.allureRuntime;
|
|
244
|
-
const suite = scope.startGroup(suiteName || "Global");
|
|
245
|
-
this.suites.push(suite);
|
|
246
|
-
this.runningItems = [];
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
onPrerequest(
|
|
250
|
-
_err: any,
|
|
251
|
-
args: {
|
|
252
|
-
executions: Event[];
|
|
253
|
-
},
|
|
254
|
-
) {
|
|
255
|
-
const execScript = args.executions[0]?.script.exec?.join("\n");
|
|
256
|
-
|
|
257
|
-
if (this.currentRunningItem && execScript) {
|
|
258
|
-
this.currentRunningItem.pmItem.prerequest = execScript;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
onBeforeItem(_err: any, args: { item: Item; cursor: Cursor }) {
|
|
263
|
-
const pmItem: PmItem = {
|
|
264
|
-
name: args.item.name,
|
|
265
|
-
passed: true,
|
|
266
|
-
failedAssertions: [],
|
|
267
|
-
consoleLogs: [],
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
if (this.currentSuite === null) {
|
|
271
|
-
throw new Error("No active suite");
|
|
272
|
-
}
|
|
273
|
-
const testName = pmItem.name;
|
|
274
|
-
|
|
275
|
-
const allureTest = this.currentSuite.startTest(testName);
|
|
276
|
-
|
|
277
|
-
allureTest.stage = Stage.RUNNING;
|
|
278
|
-
|
|
279
|
-
const itemGroup = args.item.parent();
|
|
280
|
-
|
|
281
|
-
const item = args.item;
|
|
282
|
-
const fullName = this.getFullName(item);
|
|
283
|
-
if (itemGroup && this.currentNMGroup !== itemGroup) {
|
|
284
|
-
this.currentNMGroup = itemGroup as any;
|
|
285
|
-
}
|
|
286
|
-
const testPath = this.pathToItem(item);
|
|
287
|
-
if (testPath[0]) {
|
|
288
|
-
allureTest.addLabel(LabelName.PARENT_SUITE, testPath[0]);
|
|
289
|
-
}
|
|
290
|
-
if (testPath[1]) {
|
|
291
|
-
allureTest.addLabel(LabelName.SUITE, testPath[1]);
|
|
292
|
-
}
|
|
293
|
-
const subSuites = testPath.slice(2);
|
|
294
|
-
|
|
295
|
-
if (subSuites.length) {
|
|
296
|
-
allureTest.addLabel(LabelName.SUB_SUITE, subSuites.join(" > "));
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
allureTest.fullName = fullName;
|
|
300
|
-
allureTest.testCaseId = md5(fullName);
|
|
301
|
-
const { labels } = extractMeta(args.item.events);
|
|
302
|
-
|
|
303
|
-
labels.forEach((label) => {
|
|
304
|
-
allureTest.addLabel(label.name, label.value);
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
this.runningItems.push({
|
|
308
|
-
name: fullName,
|
|
309
|
-
allureTest: allureTest,
|
|
310
|
-
pmItem: pmItem,
|
|
311
|
-
steps: [],
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
onItem(
|
|
316
|
-
_err: any,
|
|
317
|
-
args: {
|
|
318
|
-
item: Item;
|
|
319
|
-
},
|
|
320
|
-
) {
|
|
321
|
-
if (this.currentRunningItem?.pmItem.prerequest) {
|
|
322
|
-
this.attachString("PreRequest", this.currentRunningItem.pmItem.prerequest);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
if (this.currentRunningItem?.pmItem.testScript) {
|
|
326
|
-
this.attachString("TestScript", this.currentRunningItem.pmItem.testScript);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
if (this.currentRunningItem?.pmItem.consoleLogs.length) {
|
|
330
|
-
this.attachString("ConsoleLogs", this.currentRunningItem.pmItem.consoleLogs);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
const requestData = this.currentRunningItem?.pmItem.requestData;
|
|
334
|
-
const requestDataURL = requestData && `${requestData.method} - ${requestData.url}`;
|
|
335
|
-
|
|
336
|
-
if (requestData?.body?.mode === "raw" && requestData.body.raw) {
|
|
337
|
-
this.currentExecutable.addParameter("Request body", requestData.body.raw);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
let testDescription = "";
|
|
341
|
-
|
|
342
|
-
const rawDescription = args.item.request.description;
|
|
343
|
-
if (rawDescription !== undefined) {
|
|
344
|
-
if (typeof rawDescription === "string") {
|
|
345
|
-
testDescription = rawDescription;
|
|
346
|
-
} else {
|
|
347
|
-
testDescription = rawDescription.content;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
testDescription = testDescription.replace(/[*]/g, "");
|
|
351
|
-
testDescription = testDescription.replace(/\n/g, "<br>");
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
if (requestDataURL) {
|
|
355
|
-
this.currentExecutable.addParameter("Request", requestDataURL);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
const response = this.currentRunningItem?.pmItem.responseData;
|
|
359
|
-
if (response?.code) {
|
|
360
|
-
this.currentExecutable.addParameter("Response Code", response?.code.toString(), {
|
|
361
|
-
excluded: true,
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
if (testDescription) {
|
|
366
|
-
this.setDescriptionHtml(testDescription);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
if (response?.body) {
|
|
370
|
-
const attachment = this.allureRuntime.writeAttachment(response.body, {
|
|
371
|
-
contentType: ContentType.TEXT,
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
this.currentExecutable.addAttachment(
|
|
375
|
-
"response",
|
|
376
|
-
{ contentType: ContentType.TEXT },
|
|
377
|
-
attachment,
|
|
378
|
-
);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
const failedAssertions = this.currentRunningItem?.pmItem.failedAssertions;
|
|
382
|
-
if (response && failedAssertions?.length) {
|
|
383
|
-
const msg = this.escape(failedAssertions.join(", "));
|
|
384
|
-
const details = this.escape(`Response code: ${response.code}, status: ${response.status}`);
|
|
385
|
-
|
|
386
|
-
const error = {
|
|
387
|
-
name: "AssertionError",
|
|
388
|
-
message: msg,
|
|
389
|
-
trace: details,
|
|
390
|
-
};
|
|
391
|
-
const latestStatus = this.currentRunningItem?.allureTest.status;
|
|
392
|
-
|
|
393
|
-
// if test already has a failed state, we should not overwrite it
|
|
394
|
-
if (latestStatus === Status.FAILED || latestStatus === Status.BROKEN) {
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
const status = error.name === "AssertionError" ? Status.FAILED : Status.BROKEN;
|
|
398
|
-
|
|
399
|
-
if (this.currentRunningItem) {
|
|
400
|
-
this.endTest(this.currentRunningItem.allureTest, status, { message: error.message });
|
|
401
|
-
}
|
|
402
|
-
} else if (this.currentRunningItem) {
|
|
403
|
-
this.endTest(this.currentRunningItem?.allureTest, Status.PASSED);
|
|
404
|
-
}
|
|
405
|
-
this.runningItems.pop();
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
onTest(
|
|
409
|
-
_err: any,
|
|
410
|
-
args: {
|
|
411
|
-
executions: Event[];
|
|
412
|
-
},
|
|
413
|
-
) {
|
|
414
|
-
const execScript = args.executions[0]?.script.exec?.join("\n");
|
|
415
|
-
|
|
416
|
-
if (this.currentRunningItem && execScript) {
|
|
417
|
-
this.currentRunningItem.pmItem.testScript = execScript;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
onConsole(err: any, args: ConsoleEvent) {
|
|
422
|
-
if (err) {
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
if (args.level) {
|
|
427
|
-
this.currentRunningItem?.pmItem.consoleLogs.push(
|
|
428
|
-
`level: ${args.level}, messages: ${args.messages.toString()}`,
|
|
429
|
-
);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
onRequest(
|
|
434
|
-
err: any,
|
|
435
|
-
args: {
|
|
436
|
-
request: Request;
|
|
437
|
-
response: Response;
|
|
438
|
-
},
|
|
439
|
-
) {
|
|
440
|
-
if (err) {
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
const req = args.request;
|
|
445
|
-
|
|
446
|
-
const url = `${
|
|
447
|
-
req.url.protocol || ""
|
|
448
|
-
}://${args.request.url.getHost()}${req.url.getPathWithQuery()}`;
|
|
449
|
-
|
|
450
|
-
const respStream = args.response.stream;
|
|
451
|
-
const respBody = (respStream && Buffer.from(respStream).toString()) || "";
|
|
452
|
-
|
|
453
|
-
this.runningItems[this.runningItems.length - 1].pmItem.requestData = {
|
|
454
|
-
url: url,
|
|
455
|
-
method: req.method,
|
|
456
|
-
body: req.body,
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
this.runningItems[this.runningItems.length - 1].pmItem.responseData = {
|
|
460
|
-
status: args.response.status,
|
|
461
|
-
code: args.response.code,
|
|
462
|
-
body: respBody,
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
onAssertion(err: any, args: NewmanRunExecutionAssertion) {
|
|
467
|
-
const stepName = args.assertion;
|
|
468
|
-
const currStep = this.startStep(stepName);
|
|
469
|
-
|
|
470
|
-
if (err && this.currentRunningItem) {
|
|
471
|
-
this.currentRunningItem.pmItem.passed = false;
|
|
472
|
-
this.currentRunningItem.pmItem.failedAssertions.push(args.assertion);
|
|
473
|
-
|
|
474
|
-
currStep.status = Status.FAILED;
|
|
475
|
-
currStep.stage = Stage.FINISHED;
|
|
476
|
-
currStep.endStep();
|
|
477
|
-
} else {
|
|
478
|
-
currStep.stage = Stage.FINISHED;
|
|
479
|
-
currStep.status = Status.PASSED;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
onDone(_err: any, _args: unknown) {
|
|
484
|
-
if (this.currentSuite) {
|
|
485
|
-
this.currentSuite.endGroup();
|
|
486
|
-
this.suites.pop();
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
if (this.reporterOptions.postProcessorForTest) {
|
|
490
|
-
this.reporterOptions.postProcessorForTest(this.allureWriter);
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
export = AllureReporter;
|
package/testops-preview.png
DELETED
|
Binary file
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { InMemoryAllureWriter, TestResult } from "allure-js-commons";
|
|
2
|
-
import { run } from "newman";
|
|
3
|
-
import { CollectionDefinition } from "postman-collection";
|
|
4
|
-
|
|
5
|
-
export const runNewman = async (collection: CollectionDefinition): Promise<TestResult[]> => {
|
|
6
|
-
return new Promise((resolve) => {
|
|
7
|
-
run({
|
|
8
|
-
collection,
|
|
9
|
-
reporters: ["allure"],
|
|
10
|
-
reporter: {
|
|
11
|
-
allure: {
|
|
12
|
-
postProcessorForTest: (res: InMemoryAllureWriter) => {
|
|
13
|
-
resolve(res.tests);
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
};
|
package/tests/mocks/handlers.ts
DELETED
package/tests/mocks/server.ts
DELETED
package/tests/overview.test.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/quotes */
|
|
2
|
-
import { md5, Status } from "allure-js-commons";
|
|
3
|
-
import { runNewman } from "./helpers/runNewman";
|
|
4
|
-
import { server } from "./mocks/server";
|
|
5
|
-
|
|
6
|
-
beforeAll(() => server.listen());
|
|
7
|
-
afterEach(() => server.resetHandlers());
|
|
8
|
-
afterAll(() => server.close());
|
|
9
|
-
|
|
10
|
-
test("complex test overview", async () => {
|
|
11
|
-
const [result] = await runNewman({
|
|
12
|
-
info: {
|
|
13
|
-
name: "fff",
|
|
14
|
-
},
|
|
15
|
-
item: [
|
|
16
|
-
{
|
|
17
|
-
name: "ParentName",
|
|
18
|
-
item: [
|
|
19
|
-
{
|
|
20
|
-
name: "SuiteName",
|
|
21
|
-
item: [
|
|
22
|
-
{
|
|
23
|
-
name: "SubSub1",
|
|
24
|
-
item: [
|
|
25
|
-
{
|
|
26
|
-
name: "SubSub1",
|
|
27
|
-
item: [
|
|
28
|
-
{
|
|
29
|
-
name: "testReq",
|
|
30
|
-
event: [
|
|
31
|
-
{
|
|
32
|
-
listen: "test",
|
|
33
|
-
script: {
|
|
34
|
-
exec: [
|
|
35
|
-
"//@allure.id=228",
|
|
36
|
-
"//@allure.label.custom=test",
|
|
37
|
-
'pm.test("Status code is 200", function () {',
|
|
38
|
-
" pm.response.to.have.status(200);",
|
|
39
|
-
"});",
|
|
40
|
-
],
|
|
41
|
-
type: "text/javascript",
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
request: {
|
|
46
|
-
description: "testDescription\n\nmultiline\n\n**somethingBold**",
|
|
47
|
-
method: "GET",
|
|
48
|
-
header: [],
|
|
49
|
-
url: {
|
|
50
|
-
host: ["example", "com"],
|
|
51
|
-
path: ["test"],
|
|
52
|
-
query: [
|
|
53
|
-
{
|
|
54
|
-
key: "dfgdfg",
|
|
55
|
-
value: null,
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
response: [],
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
});
|
|
72
|
-
const name = "testReq";
|
|
73
|
-
const fullName = `ParentName/SuiteName/SubSub1/SubSub1#${name}`;
|
|
74
|
-
|
|
75
|
-
expect(result.status).toBe(Status.PASSED);
|
|
76
|
-
expect(result.name).toBe(name);
|
|
77
|
-
expect(result.parameters).toEqual([
|
|
78
|
-
{ name: "Request", value: "GET - http://example.com/test?dfgdfg" },
|
|
79
|
-
{ name: "Response Code", value: "200", excluded: true },
|
|
80
|
-
]);
|
|
81
|
-
|
|
82
|
-
expect(result.steps).toEqual([
|
|
83
|
-
{
|
|
84
|
-
status: "passed" as any,
|
|
85
|
-
stage: "finished" as any,
|
|
86
|
-
statusDetails: {},
|
|
87
|
-
steps: [],
|
|
88
|
-
attachments: [],
|
|
89
|
-
parameters: [],
|
|
90
|
-
name: "Status code is 200",
|
|
91
|
-
start: expect.any(Number),
|
|
92
|
-
},
|
|
93
|
-
]);
|
|
94
|
-
expect(result.descriptionHtml).toBe("testDescription<br><br>multiline<br><br>somethingBold");
|
|
95
|
-
expect(result.labels).toEqual([
|
|
96
|
-
{ name: "parentSuite", value: "ParentName" },
|
|
97
|
-
{ name: "suite", value: "SuiteName" },
|
|
98
|
-
{ name: "subSuite", value: "SubSub1 > SubSub1" },
|
|
99
|
-
{ name: "AS_ID", value: "228" },
|
|
100
|
-
{ name: "custom", value: "test" },
|
|
101
|
-
]);
|
|
102
|
-
|
|
103
|
-
expect(result.fullName).toBe(fullName);
|
|
104
|
-
expect(result.testCaseId).toBe(md5(fullName));
|
|
105
|
-
});
|