@wdio/junit-reporter 9.29.0 → 9.30.1

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/build/index.d.ts CHANGED
@@ -28,6 +28,12 @@ declare class JunitReporter extends WDIOReporter {
28
28
  private _appendConsoleLog;
29
29
  private _prepareName;
30
30
  private _addFailedHooks;
31
+ /**
32
+ * Build a single <testcase> element from a TestStats entry. Shared between plain
33
+ * Mocha/Jasmine suites (`_addSuiteToBuilder`) and Cucumber feature suites whose
34
+ * scenarios are reported directly as tests (`cucumberOpts.scenarioLevelReporter`).
35
+ */
36
+ private _buildTestCase;
31
37
  private _addCucumberFeatureToBuilder;
32
38
  private _addSuiteToBuilder;
33
39
  private _buildJunitXml;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAc,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACxE,OAAO,YAAY,MAAM,gBAAgB,CAAA;AAGzC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAmBtD;;;;;GAKG;AACH,cAAM,aAAc,SAAQ,YAAY;IAajB,OAAO,EAAE,oBAAoB;IAZhD,OAAO,CAAC,eAAe,CAAQ;IAC/B,OAAO,CAAC,YAAY,CAAC,CAAQ;IAC7B,OAAO,CAAC,gBAAgB,CAAC,CAAQ;IACjC,OAAO,CAAC,cAAc,CAAC,CAAQ;IAC/B,OAAO,CAAC,cAAc,CAAC,CAAK;IAC5B,OAAO,CAAC,kBAAkB,CAAC,CAAK;IAChC,OAAO,CAAC,4BAA4B,CAAwD;IAC5F,OAAO,CAAC,YAAY,CAAC,CAAW;IAChC,OAAO,CAAC,oBAAoB,CAAU;IACtC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,UAAU,CAAS;gBAER,OAAO,EAAE,oBAAoB;IAiBhD,WAAW,CAAC,S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E,SAAS;IAIhC,WAAW,CAAC,IAAI,EAAE,SAAS;IAU3B,WAAW,CAAC,MAAM,EAAE,WAAW;IAK/B,OAAO,CAAC,yBAAyB;IAMjC,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,eAAe;IAkBvB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IA+CtB,OAAO,CAAC,4BAA4B;IA6GpC,OAAO,CAAC,kBAAkB;IAqC1B,OAAO,CAAC,cAAc;IA2CtB,OAAO,CAAC,mBAAmB;IAwC3B,OAAO,CAAC,kBAAkB;IAkB1B,OAAO,CAAC,yBAAyB;IAoBjC,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,aAAa;CAgBxB;AAED,cAAc,iBAAiB,CAAA;AAC/B,eAAe,aAAa,CAAA"}
package/build/index.js CHANGED
@@ -152,6 +152,54 @@ var JunitReporter = class extends WDIOReporter {
152
152
  });
153
153
  return suite;
154
154
  }
155
+ /**
156
+ * Build a single <testcase> element from a TestStats entry. Shared between plain
157
+ * Mocha/Jasmine suites (`_addSuiteToBuilder`) and Cucumber feature suites whose
158
+ * scenarios are reported directly as tests (`cucumberOpts.scenarioLevelReporter`).
159
+ */
160
+ _buildTestCase(testSuiteBuilder, test, filePath, classNameFormat) {
161
+ const testName = this._prepareName(test.title);
162
+ const testCase = testSuiteBuilder.testCase().className(classNameFormat).name(testName).time(test._duration / 1e3);
163
+ if (this.options.addFileAttribute) {
164
+ testCase.file(filePath);
165
+ }
166
+ if (test.state === "pending" || test.state === "skipped") {
167
+ testCase.skipped();
168
+ if (test.error) {
169
+ testCase.standardError(`
170
+ ${test.error.stack?.replace(ansiRegex, "") ?? ""}
171
+ `);
172
+ }
173
+ } else if (test.state === "failed") {
174
+ if (test.error) {
175
+ if (test.error.message) {
176
+ test.error.message = test.error.message.replace(ansiRegex, "");
177
+ }
178
+ if (this.options.errorOptions) {
179
+ const errorOptions = this.options.errorOptions;
180
+ for (const key of Object.keys(errorOptions)) {
181
+ testCase[key](test.error[errorOptions[key]]);
182
+ }
183
+ } else {
184
+ testCase.failure(test.error.message);
185
+ }
186
+ testCase.standardError(`
187
+ ${test.error.stack?.replace(ansiRegex, "") ?? ""}
188
+ `);
189
+ } else {
190
+ testCase.failure();
191
+ }
192
+ }
193
+ for (const propName of Object.keys(this._testToAdditionalInformation[test.uid]?.properties ?? {})) {
194
+ testCase.property(propName, this._testToAdditionalInformation[test.uid].properties[propName]);
195
+ }
196
+ const output = this._getStandardOutput(test);
197
+ if (output) {
198
+ testCase.standardOutput(`
199
+ ${output}
200
+ `);
201
+ }
202
+ }
155
203
  _addCucumberFeatureToBuilder(builder, runner, specFileName, suite) {
156
204
  const featureName = !this.options.suiteNameFormat || this.options.suiteNameFormat instanceof RegExp ? this._prepareName(suite.title) : this.options.suiteNameFormat({ name: this.options.suiteNameFormat.name, suite });
157
205
  const filePath = specFileName.replace(process.cwd(), ".");
@@ -159,6 +207,14 @@ var JunitReporter = class extends WDIOReporter {
159
207
  const feature = builder.testSuite().name(featureName).timestamp(suite.start).time(suite._duration / 1e3).property("specId", 0).property(this._suiteTitleLabel, suite.title).property("capabilities", runner.sanitizedCapabilities).property(this._fileNameLabel, filePath);
160
208
  this._activeFeature = feature;
161
209
  this._activeFeatureName = featureName;
210
+ for (const testKey of Object.keys(suite.tests)) {
211
+ if (testKey === "undefined") {
212
+ continue;
213
+ }
214
+ const test = suite.tests[testKey];
215
+ const classNameFormat = this.options.classNameFormat ? this.options.classNameFormat({ packageName: this._packageName, activeFeatureName: featureName }) : `${this._packageName}.${featureName}`;
216
+ this._buildTestCase(feature, test, filePath, classNameFormat);
217
+ }
162
218
  } else if (this._activeFeature) {
163
219
  let scenario = suite;
164
220
  const testName = this._prepareName(suite.title);
@@ -183,6 +239,9 @@ var JunitReporter = class extends WDIOReporter {
183
239
  stepEmoji = "\u26A0\uFE0F";
184
240
  } else if (step.state === "failed") {
185
241
  if (step.error) {
242
+ if (step.error.message) {
243
+ step.error.message = step.error.message.replace(ansiRegex, "");
244
+ }
186
245
  if (this.options.errorOptions) {
187
246
  const errorOptions = this.options.errorOptions;
188
247
  for (const key of Object.keys(errorOptions)) {
@@ -194,7 +253,7 @@ var JunitReporter = class extends WDIOReporter {
194
253
  testCase.failure(step.error.message);
195
254
  }
196
255
  testCase.standardError(`
197
- ${step.error.stack}
256
+ ${step.error.stack?.replace(ansiRegex, "") ?? ""}
198
257
  `);
199
258
  } else {
200
259
  testCase.failure();
@@ -230,48 +289,8 @@ ${stepsOutput}
230
289
  continue;
231
290
  }
232
291
  const test = suite.tests[testKey];
233
- const testName = this._prepareName(test.title);
234
292
  const classNameFormat = this.options.classNameFormat ? this.options.classNameFormat({ packageName: this._packageName, suite }) : `${this._packageName}.${(suite.fullTitle || suite.title).replace(/\s/g, "_")}`;
235
- const testCase = testSuite.testCase().className(classNameFormat).name(testName).time(test._duration / 1e3);
236
- if (this.options.addFileAttribute) {
237
- testCase.file(filePath);
238
- }
239
- if (test.state === "pending" || test.state === "skipped") {
240
- testCase.skipped();
241
- if (test.error) {
242
- testCase.standardError(`
243
- ${test.error.stack?.replace(ansiRegex, "")}
244
- `);
245
- }
246
- } else if (test.state === "failed") {
247
- if (test.error) {
248
- if (test.error.message) {
249
- test.error.message = test.error.message.replace(ansiRegex, "");
250
- }
251
- if (this.options.errorOptions) {
252
- const errorOptions = this.options.errorOptions;
253
- for (const key of Object.keys(errorOptions)) {
254
- testCase[key](test.error[errorOptions[key]]);
255
- }
256
- } else {
257
- testCase.failure(test.error.message);
258
- }
259
- testCase.standardError(`
260
- ${test.error.stack?.replace(ansiRegex, "")}
261
- `);
262
- } else {
263
- testCase.failure();
264
- }
265
- }
266
- for (const propName of Object.keys(this._testToAdditionalInformation[test.uid]?.properties ?? {})) {
267
- testCase.property(propName, this._testToAdditionalInformation[test.uid].properties[propName]);
268
- }
269
- const output = this._getStandardOutput(test);
270
- if (output) {
271
- testCase.standardOutput(`
272
- ${output}
273
- `);
274
- }
293
+ this._buildTestCase(testSuite, test, filePath, classNameFormat);
275
294
  }
276
295
  return builder;
277
296
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/junit-reporter",
3
- "version": "9.29.0",
3
+ "version": "9.30.1",
4
4
  "description": "A WebdriverIO reporter that creates Jenkins compatible XML based JUnit reports",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-junit-reporter",
@@ -35,8 +35,8 @@
35
35
  },
36
36
  "typeScriptVersion": "3.8.3",
37
37
  "dependencies": {
38
- "@wdio/reporter": "9.29.0",
39
- "@wdio/types": "9.29.0",
38
+ "@wdio/reporter": "9.30.1",
39
+ "@wdio/types": "9.30.1",
40
40
  "json-stringify-safe": "^5.0.1",
41
41
  "junit-report-builder": "^5.1.1"
42
42
  },
@@ -46,5 +46,5 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "gitHead": "c7808c59ca3ab6a677230cebd688454426cba0f2"
49
+ "gitHead": "2ea7c6945a5ec1fa0edd89fe7d3f821dc29201d8"
50
50
  }