New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@wdio/junit-reporter

Package Overview
Dependencies
Maintainers
0
Versions
307
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wdio/junit-reporter - npm Package Compare versions

Comparing version 9.0.8 to 9.1.0

build/common/api.d.ts

9

build/index.d.ts

@@ -18,5 +18,12 @@ import type { RunnerStats, TestStats } from '@wdio/reporter';

private _activeFeatureName?;
private _testToAdditionalInformation;
private _currentTest?;
private _originalStdoutWrite;
private _addWorkerLogs;
constructor(options: JUnitReporterOptions);
onTestRetry(testStats: TestStats): void;
onTestStart(test: TestStats): void;
onRunnerEnd(runner: RunnerStats): void;
private _addPropertyToCurrentTest;
private _appendConsoleLog;
private _prepareName;

@@ -29,6 +36,8 @@ private _addFailedHooks;

private _getStandardOutput;
private _getCommandStandardOutput;
private _format;
private _sameFileName;
}
export * from './common/api.js';
export default JunitReporter;
//# sourceMappingURL=index.d.ts.map

67

build/index.js

@@ -64,2 +64,13 @@ // src/index.ts

// src/common/api.ts
var events = {
addProperty: "junit:addProperty"
};
var tellReporter = (event, msg = {}) => {
process.emit(event, msg);
};
function addProperty(name, value) {
tellReporter(events.addProperty, { name, value });
}
// src/index.ts

@@ -74,3 +85,11 @@ var ansiRegex = new RegExp([

this.options = options;
this._addWorkerLogs = options.addWorkerLogs ?? false;
this._testToAdditionalInformation = {};
this._originalStdoutWrite = process.stdout.write.bind(process.stdout);
this._suiteNameRegEx = this.options.suiteNameFormat instanceof RegExp ? this.options.suiteNameFormat : /[^a-zA-Z0-9@]+/;
const processObj = process;
if (this._addWorkerLogs) {
processObj.stdout.write = this._appendConsoleLog.bind(this);
}
processObj.on(events.addProperty, this._addPropertyToCurrentTest.bind(this));
}

@@ -83,5 +102,17 @@ _suiteNameRegEx;

_activeFeatureName;
_testToAdditionalInformation;
_currentTest;
_originalStdoutWrite;
_addWorkerLogs;
onTestRetry(testStats) {
testStats.skip("Retry");
}
onTestStart(test) {
this._currentTest = test;
this._testToAdditionalInformation[test.uid] = {
workerConsoleLog: "",
properties: {},
uid: test.uid
};
}
onRunnerEnd(runner) {

@@ -91,2 +122,15 @@ const xml = this._buildJunitXml(runner);

}
_addPropertyToCurrentTest(dataObj) {
if (this._currentTest?.uid) {
this._testToAdditionalInformation[this._currentTest.uid].properties[dataObj.name] = dataObj.value;
}
}
_appendConsoleLog(chunk, encoding, callback) {
if (this._currentTest?.uid) {
if (typeof chunk === "string" && !chunk.includes("mwebdriver")) {
this._testToAdditionalInformation[this._currentTest.uid].workerConsoleLog = (this._testToAdditionalInformation[this._currentTest.uid].workerConsoleLog ?? "") + chunk;
}
}
return this._originalStdoutWrite(chunk, encoding, callback);
}
_prepareName(name = "Skipped test") {

@@ -213,2 +257,5 @@ return name.split(this._suiteNameRegEx).filter(

}
for (const propName of Object.keys(this._testToAdditionalInformation[test.uid]?.properties ?? {})) {
testCase.property(propName, this._testToAdditionalInformation[test.uid].properties[propName]);
}
const output = this._getStandardOutput(test);

@@ -273,2 +320,18 @@ if (output) {

_getStandardOutput(test) {
let consoleOutput = "";
if (this._addWorkerLogs) {
consoleOutput = this._testToAdditionalInformation[test.uid]?.workerConsoleLog ?? "";
}
const commandText = this._getCommandStandardOutput(test);
let result = "";
if (consoleOutput !== "") {
result += consoleOutput;
}
if (commandText !== "" && consoleOutput !== "") {
result += "\n...command output...\n\n";
}
result += commandText;
return result;
}
_getCommandStandardOutput(test) {
const standardOutput = [];

@@ -300,3 +363,5 @@ test.output.forEach((data) => {

export {
src_default as default
addProperty,
src_default as default,
events
};

@@ -112,4 +112,26 @@ import type { Reporters } from '@wdio/types';

errorOptions?: Record<string, string>;
/**
* Optional parameter, set this parameter to true in order to attach console logs from the test in the reporter.
* @default false
*
* @example
*
* ```js
* // wdio.conf.js
* module.exports = {
* // ...
* reporters: [
* 'dot',
* ['junit', {
* outputDir: './',
* addWorkerLogs: true
* }]
* ],
* // ...
* };
* ```
*/
addWorkerLogs?: boolean;
}
export {};
//# sourceMappingURL=types.d.ts.map

12

package.json
{
"name": "@wdio/junit-reporter",
"version": "9.0.8",
"version": "9.1.0",
"description": "A WebdriverIO reporter that creates Jenkins compatible XML based JUnit reports",

@@ -30,4 +30,6 @@ "author": "Christian Bromann <mail@bromann.dev>",

".": {
"types": "./build/index.d.ts",
"import": "./build/index.js",
"types": "./build/index.d.ts"
"requireSource": "./src/common/api.ts",
"require": "./build/index.cjs"
}

@@ -37,4 +39,4 @@ },

"dependencies": {
"@wdio/reporter": "9.0.8",
"@wdio/types": "9.0.8",
"@wdio/reporter": "9.1.0",
"@wdio/types": "9.1.0",
"json-stringify-safe": "^5.0.1",

@@ -49,3 +51,3 @@ "junit-report-builder": "^3.0.0"

},
"gitHead": "cc85ebf08918965cff46ce7e014703549b7f50d7"
"gitHead": "e6b005f5a150c335a105cfc2e386d43ac526adac"
}

@@ -273,2 +273,46 @@ WebdriverIO XML Reporter

### addWorkerLogs
Optional parameter, set this parameter to true in order to attach console logs from the test in the reporter.
Type: `Boolean`<br />
Default: `false`<br />
Example:
```js
// wdio.conf.js
module.exports = {
// ...
reporters: [
'dot',
['junit', {
outputDir: './',
addWorkerLogs: true
}]
],
// ...
};
```
## Adding custom properties to testcases
This plugin provides a function `addProperty(name, value)`. This function may be used to add additional junit testcase properties to the currently running test step. These properties will be reported in the resulting xml as `<property name="${name}" value="${value}" />`.
Typical usecase for this is adding a link to an issue or a testcase.
### Usage example
An example for mocha:
```js
import { addProperty } from '@wdio/junit-reporter'
describe('Suite', () => {
it('Case', () => {
addProperty('test_case', 'TC-1234')
})
})
```
## Jenkins Setup

@@ -275,0 +319,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc