@allurereport/reader 3.0.1 → 3.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.
@@ -30,6 +30,7 @@ const xmlParser = new XMLParser({
30
30
  attributeNamePrefix: "",
31
31
  removeNSPrefix: true,
32
32
  allowBooleanAttributes: true,
33
+ processEntities: false,
33
34
  isArray: arrayTags.has.bind(arrayTags),
34
35
  });
35
36
  const readerId = "allure1";
@@ -13,36 +13,45 @@ const xmlParser = new XMLParser({
13
13
  attributeNamePrefix: "",
14
14
  removeNSPrefix: true,
15
15
  allowBooleanAttributes: true,
16
+ processEntities: false,
16
17
  isArray: (tagName, jPath) => arrayTags.has(jPath),
17
18
  });
18
19
  const readerId = "allure2";
19
20
  export const allure2 = {
20
21
  read: async (visitor, data) => {
21
- if (data.getOriginalFileName().match(/-attachment(?:\..+)?/)) {
22
+ const originalFileName = data.getOriginalFileName();
23
+ if (originalFileName.match(/-attachment(?:\..+)?/)) {
22
24
  await visitor.visitAttachmentFile(data, { readerId });
23
25
  return true;
24
26
  }
25
- if (data.getOriginalFileName().endsWith("-result.json")) {
27
+ if (originalFileName.endsWith("-result.json")) {
26
28
  try {
27
29
  const parsed = await data.asJson();
28
30
  if (parsed && isStringAnyRecord(parsed)) {
29
- await processTestResult(visitor, parsed, data.getOriginalFileName());
31
+ await processTestResult(visitor, parsed, originalFileName);
30
32
  }
31
33
  return true;
32
34
  }
33
35
  catch (e) {
34
- console.error("error parsing", data.getOriginalFileName(), e);
36
+ console.error("error parsing", originalFileName, e);
35
37
  return false;
36
38
  }
37
39
  }
38
- if (data.getOriginalFileName().endsWith("-container.json")) {
40
+ if (originalFileName.endsWith("-container.json")) {
39
41
  const parsed = await data.asJson();
40
42
  if (parsed) {
41
43
  await processTestResultContainer(visitor, parsed);
42
44
  }
43
45
  return true;
44
46
  }
45
- if (data.getOriginalFileName() === "executor.json") {
47
+ if (originalFileName.endsWith("-globals.json")) {
48
+ const parsed = await data.asJson();
49
+ if (parsed) {
50
+ await processGlobals(visitor, parsed);
51
+ }
52
+ return true;
53
+ }
54
+ if (originalFileName === "executor.json") {
46
55
  try {
47
56
  const parsed = await data.asJson();
48
57
  if (parsed && isStringAnyRecord(parsed)) {
@@ -51,11 +60,11 @@ export const allure2 = {
51
60
  return true;
52
61
  }
53
62
  catch (e) {
54
- console.error("error parsing", data.getOriginalFileName(), e);
63
+ console.error("error parsing", originalFileName, e);
55
64
  return false;
56
65
  }
57
66
  }
58
- if (data.getOriginalFileName() === "categories.json") {
67
+ if (originalFileName === "categories.json") {
59
68
  try {
60
69
  const parsed = await data.asJson();
61
70
  if (parsed && isStringAnyRecordArray(parsed)) {
@@ -64,11 +73,11 @@ export const allure2 = {
64
73
  return true;
65
74
  }
66
75
  catch (e) {
67
- console.error("error parsing", data.getOriginalFileName(), e);
76
+ console.error("error parsing", originalFileName, e);
68
77
  return false;
69
78
  }
70
79
  }
71
- if (data.getOriginalFileName() === "environment.properties") {
80
+ if (originalFileName === "environment.properties") {
72
81
  try {
73
82
  const raw = await data.asUtf8String();
74
83
  if (raw) {
@@ -80,11 +89,11 @@ export const allure2 = {
80
89
  return true;
81
90
  }
82
91
  catch (e) {
83
- console.error("error parsing", data.getOriginalFileName(), e);
92
+ console.error("error parsing", originalFileName, e);
84
93
  return false;
85
94
  }
86
95
  }
87
- if (data.getOriginalFileName() === "environment.xml") {
96
+ if (originalFileName === "environment.xml") {
88
97
  try {
89
98
  const asBuffer = await data.asBuffer();
90
99
  if (!asBuffer) {
@@ -98,7 +107,7 @@ export const allure2 = {
98
107
  return true;
99
108
  }
100
109
  catch (e) {
101
- console.error("error parsing", data.getOriginalFileName(), e);
110
+ console.error("error parsing", originalFileName, e);
102
111
  return false;
103
112
  }
104
113
  }
@@ -219,6 +228,13 @@ const processTestResultContainer = async (visitor, result) => {
219
228
  await processFixtures(visitor, result.afters, "after", result.children);
220
229
  }
221
230
  };
231
+ const processGlobals = async (visitor, globals) => {
232
+ const { attachments = [], errors = [] } = globals;
233
+ await visitor.visitGlobals({
234
+ attachments: Array.isArray(attachments) ? attachments.map((attachment) => convertAttachment(attachment)) : [],
235
+ errors: isStringAnyRecordArray(errors) ? errors : [],
236
+ }, { readerId });
237
+ };
222
238
  const convertStatus = (status) => {
223
239
  switch ((status ?? "unknown").toLowerCase()) {
224
240
  case "failed":
@@ -76,4 +76,8 @@ export interface TestResultContainer {
76
76
  befores?: FixtureResult[];
77
77
  afters?: FixtureResult[];
78
78
  }
79
+ export interface Globals {
80
+ attachments: Attachment[];
81
+ errors: StatusDetails[];
82
+ }
79
83
  export {};
@@ -19,6 +19,7 @@ const xmlParser = new XMLParser({
19
19
  attributeNamePrefix: "",
20
20
  removeNSPrefix: true,
21
21
  allowBooleanAttributes: true,
22
+ processEntities: false,
22
23
  isArray: (tagName, jPath) => arrayTags.has(jPath),
23
24
  });
24
25
  const readerId = "junit";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/reader",
3
- "version": "3.0.1",
3
+ "version": "3.2.0",
4
4
  "description": "Collection of utilities which helps to process different kind of test results as Allure Results",
5
5
  "keywords": [
6
6
  "allure",
@@ -26,10 +26,10 @@
26
26
  "test": "vitest run"
27
27
  },
28
28
  "dependencies": {
29
- "@allurereport/core-api": "3.0.1",
30
- "@allurereport/plugin-api": "3.0.1",
31
- "@allurereport/reader-api": "3.0.1",
32
- "fast-xml-parser": "^4.5.0"
29
+ "@allurereport/core-api": "3.2.0",
30
+ "@allurereport/plugin-api": "3.2.0",
31
+ "@allurereport/reader-api": "3.2.0",
32
+ "fast-xml-parser": "^5.3.6"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@stylistic/eslint-plugin": "^2.6.1",