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

wdio-reportportal-reporter

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wdio-reportportal-reporter - npm Package Compare versions

Comparing version 5.2.4 to 5.2.5

lib/__tests__/endSuite.spec.ts

10

build/constants.js

@@ -47,2 +47,12 @@ "use strict";

})(TYPE = exports.TYPE || (exports.TYPE = {}));
var CUCUMBER_TYPE;
(function (CUCUMBER_TYPE) {
CUCUMBER_TYPE["FEATURE"] = "feature";
CUCUMBER_TYPE["SCENARIO"] = "scenario";
})(CUCUMBER_TYPE = exports.CUCUMBER_TYPE || (exports.CUCUMBER_TYPE = {}));
var CUCUMBER_STATUS;
(function (CUCUMBER_STATUS) {
CUCUMBER_STATUS["PASSED"] = "passed";
CUCUMBER_STATUS["FAILED"] = "failed";
})(CUCUMBER_STATUS = exports.CUCUMBER_STATUS || (exports.CUCUMBER_STATUS = {}));
var MODE;

@@ -49,0 +59,0 @@ (function (MODE) {

47

build/reporter.js

@@ -29,2 +29,5 @@ "use strict";

this.registerListeners();
if (this.options.cucumberNestedSteps) {
this.featureStatus = constants_1.STATUS.PASSED;
}
}

@@ -54,3 +57,20 @@ get isSynchronised() {

log.trace(`Start suite ${suite.title} ${suite.uid}`);
const suiteStartObj = new entities_1.StartTestItem(suite.title, constants_1.TYPE.SUITE);
const suiteStartObj = this.options.cucumberNestedSteps ?
new entities_1.StartTestItem(suite.title, suite.type === constants_1.CUCUMBER_TYPE.FEATURE ? constants_1.TYPE.TEST : constants_1.TYPE.STEP) :
new entities_1.StartTestItem(suite.title, constants_1.TYPE.SUITE);
if (this.options.cucumberNestedSteps && this.options.autoAttachCucumberFeatureToScenario) {
switch (suite.type) {
case constants_1.CUCUMBER_TYPE.FEATURE:
this.featureName = suite.title;
break;
case constants_1.CUCUMBER_TYPE.SCENARIO:
suiteStartObj.attributes = [
{
key: constants_1.CUCUMBER_TYPE.FEATURE,
value: this.featureName,
},
];
break;
}
}
const suiteItem = this.storage.getCurrentSuite();

@@ -71,4 +91,17 @@ let parentId = null;

log.trace(`End suite ${suite.title} ${suite.uid}`);
let status = constants_1.STATUS.PASSED;
if (this.options.cucumberNestedSteps) {
switch (suite.type) {
case constants_1.CUCUMBER_TYPE.SCENARIO:
const scenarioStatus = suite.tests.every(({ state }) => state === constants_1.CUCUMBER_STATUS.PASSED);
status = scenarioStatus ? constants_1.STATUS.PASSED : constants_1.STATUS.FAILED;
this.featureStatus = this.featureStatus === constants_1.STATUS.PASSED && status === constants_1.STATUS.PASSED ? constants_1.STATUS.PASSED : constants_1.STATUS.FAILED;
break;
case constants_1.CUCUMBER_TYPE.FEATURE:
status = this.featureStatus;
break;
}
}
const suiteItem = this.storage.getCurrentSuite();
const finishSuiteObj = { status: constants_1.STATUS.PASSED };
const finishSuiteObj = { status };
const { promise } = this.client.finishTestItem(suiteItem.id, finishSuiteObj);

@@ -86,2 +119,5 @@ utils_1.promiseErrorHandler(promise);

testStartObj.codeRef = this.specFile;
if (this.options.cucumberNestedSteps) {
testStartObj.hasStats = false;
}
if (this.options.parseTagsFromTestTitle) {

@@ -133,2 +169,9 @@ testStartObj.addTags();

});
if (this.options.cucumberNestedSteps) {
const suiteItem = this.storage.getCurrentSuite();
this.client.sendLog(suiteItem.id, {
level: constants_1.LEVEL.ERROR,
message,
});
}
}

@@ -135,0 +178,0 @@ const { promise } = this.client.finishTestItem(testItem.id, finishTestObj);

@@ -13,2 +13,4 @@ "use strict";

this.setRetryTrue = false;
this.cucumberNestedSteps = false;
this.autoAttachCucumberFeatureToScenario = false;
this.reportPortalClientConfig = { mode: constants_1.MODE.DEFAULT, tags: [], description: "" };

@@ -15,0 +17,0 @@ }

2

lib/__tests__/fixtures/events.ts
export const suiteStartEvent = () => ({cid: "0-0", title: "foo", runner: {"0-0": {}}});
export const suiteEndEvent = {cid: "0-0", title: "foo"};
export const suiteEndEvent = () => ({cid: "0-0", title: "foo"});

@@ -1,2 +0,2 @@

import {TYPE} from "../constants";
import {CUCUMBER_TYPE, TYPE} from "../constants";
import {suiteStartEvent} from "./fixtures/events";

@@ -59,2 +59,39 @@ import {getOptions, RPClient} from "./reportportal-client.mock";

test("should support cucumber nested steps", () => {
Object.assign(reporter.options, {cucumberNestedSteps: true});
reporter.onSuiteStart(Object.assign(suiteStartEvent(), {type: CUCUMBER_TYPE.FEATURE}));
reporter.onSuiteStart(Object.assign(suiteStartEvent(), {type: CUCUMBER_TYPE.SCENARIO}));
expect(reporter.client.startTestItem).toBeCalledTimes(2);
expect(reporter.client.startTestItem).toHaveBeenNthCalledWith(
1,
{name: "foo", type: TYPE.TEST, retry: false},
reporter.tempLaunchId,
null,
);
const {id} = reporter.storage.getCurrentSuite();
expect(reporter.client.startTestItem).toHaveBeenNthCalledWith(
2,
{name: "foo", type: TYPE.STEP, retry: false},
reporter.tempLaunchId,
id,
);
});
test("should add attribute with feature name to scenario", () => {
Object.assign(reporter.options, {cucumberNestedSteps: true, autoAttachCucumberFeatureToScenario: true});
reporter.onSuiteStart(Object.assign(suiteStartEvent(), {type: CUCUMBER_TYPE.FEATURE, title: "foo"}));
reporter.onSuiteStart(Object.assign(suiteStartEvent(), {type: CUCUMBER_TYPE.SCENARIO}));
expect(reporter.featureName).toEqual("foo");
const {id} = reporter.storage.getCurrentSuite();
expect(reporter.client.startTestItem).toHaveBeenNthCalledWith(
2,
{name: "foo", type: TYPE.STEP, retry: false, attributes: [{key: CUCUMBER_TYPE.FEATURE, value: "foo"}]},
reporter.tempLaunchId,
id,
);
});
});

@@ -45,2 +45,12 @@ export enum EVENTS {

export enum CUCUMBER_TYPE {
FEATURE = "feature",
SCENARIO = "scenario",
}
export enum CUCUMBER_STATUS {
PASSED = "passed",
FAILED = "failed",
}
export enum MODE {

@@ -47,0 +57,0 @@ DEFAULT = "DEFAULT",

@@ -13,2 +13,3 @@ import {STATUS, TYPE} from "./constants";

public retry = false;
public hasStats: boolean;

@@ -15,0 +16,0 @@ constructor(name: string, type: TYPE) {

@@ -6,3 +6,3 @@ import logger from "@wdio/logger";

import * as ReportPortalClient from "reportportal-js-client";
import {EVENTS, LEVEL, STATUS, TYPE} from "./constants";
import {CUCUMBER_STATUS, CUCUMBER_TYPE, EVENTS, LEVEL, STATUS, TYPE} from "./constants";
import {EndTestItem, Issue, StartTestItem, StorageEntity} from "./entities";

@@ -55,2 +55,4 @@ import ReporterOptions from "./ReporterOptions";

private specFile: string;
private featureStatus: STATUS;
private featureName: string;

@@ -61,2 +63,6 @@ constructor(options: any) {

this.registerListeners();
if (this.options.cucumberNestedSteps) {
this.featureStatus = STATUS.PASSED;
}
}

@@ -66,3 +72,23 @@

log.trace(`Start suite ${suite.title} ${suite.uid}`);
const suiteStartObj = new StartTestItem(suite.title, TYPE.SUITE);
const suiteStartObj = this.options.cucumberNestedSteps ?
new StartTestItem(suite.title, suite.type === CUCUMBER_TYPE.FEATURE ? TYPE.TEST : TYPE.STEP) :
new StartTestItem(suite.title, TYPE.SUITE);
if (this.options.cucumberNestedSteps && this.options.autoAttachCucumberFeatureToScenario) {
switch (suite.type) {
case CUCUMBER_TYPE.FEATURE:
this.featureName = suite.title;
break;
case CUCUMBER_TYPE.SCENARIO:
suiteStartObj.attributes = [
{
key: CUCUMBER_TYPE.FEATURE,
value: this.featureName,
},
];
break;
}
}
const suiteItem = this.storage.getCurrentSuite();

@@ -88,4 +114,19 @@ let parentId = null;

log.trace(`End suite ${suite.title} ${suite.uid}`);
let status = STATUS.PASSED;
if (this.options.cucumberNestedSteps) {
switch (suite.type) {
case CUCUMBER_TYPE.SCENARIO:
const scenarioStatus = suite.tests.every(({ state }) => state === CUCUMBER_STATUS.PASSED);
status = scenarioStatus ? STATUS.PASSED : STATUS.FAILED;
this.featureStatus = this.featureStatus === STATUS.PASSED && status === STATUS.PASSED ? STATUS.PASSED : STATUS.FAILED;
break;
case CUCUMBER_TYPE.FEATURE:
status = this.featureStatus;
break;
}
}
const suiteItem = this.storage.getCurrentSuite();
const finishSuiteObj = {status: STATUS.PASSED};
const finishSuiteObj = {status};
const {promise} = this.client.finishTestItem(suiteItem.id, finishSuiteObj);

@@ -104,2 +145,6 @@ promiseErrorHandler(promise);

testStartObj.codeRef = this.specFile;
if (this.options.cucumberNestedSteps) {
testStartObj.hasStats = false;
}
if (this.options.parseTagsFromTestTitle) {

@@ -162,2 +207,10 @@ testStartObj.addTags();

});
if (this.options.cucumberNestedSteps) {
const suiteItem = this.storage.getCurrentSuite();
this.client.sendLog(suiteItem.id, {
level: LEVEL.ERROR,
message,
});
}
}

@@ -164,0 +217,0 @@

@@ -11,3 +11,5 @@ import {LEVEL, MODE} from "./constants";

public setRetryTrue = false;
public cucumberNestedSteps = false;
public autoAttachCucumberFeatureToScenario = false;
public reportPortalClientConfig = {mode: MODE.DEFAULT, tags: [], description: ""};
}
{
"name": "wdio-reportportal-reporter",
"version": "5.2.4",
"version": "5.2.5",
"description": "A WebdriverIO v5 plugin. Report results to Report Portal.",

@@ -40,9 +40,9 @@ "main": "build/reporter.js",

"@wdio/logger": "^5.16.10",
"reportportal-js-client": "^1.2.2"
"reportportal-js-client": "^1.2.3"
},
"devDependencies": {
"@types/jest": "^24.0.23",
"@types/jest": "^25.1.2",
"@types/node": "^13.1.0",
"jest": "^24.9.0",
"ts-jest": "^24.2.0",
"ts-jest": "^25.1.0",
"npm-run-all": "^4.1.5",

@@ -49,0 +49,0 @@ "rimraf": "^3.0.0",

@@ -15,4 +15,4 @@ WDIO Report Portal Reporter

"devDependencies": {
"wdio-reportportal-reporter": "5.2.4",
"wdio-reportportal-service": "5.2.4"
"wdio-reportportal-reporter": "5.2.5",
"wdio-reportportal-service": "5.2.5"
}

@@ -45,2 +45,4 @@ }

parseTagsFromTestTitle: false,
cucumberNestedSteps: false,
autoAttachCucumberFeatureToScenario: false // requires cucumberNestedSteps to be true for use
};

@@ -91,3 +93,3 @@

```js
const reporter = require('wdio-reportportal-reporter');
const reportportal = require('wdio-reportportal-reporter');
const path = require('path');

@@ -103,3 +105,3 @@ const fs = require('fs');

browser.saveScreenshot(outputFile);
reporter.sendFileToTest(test, 'info', filename, fs.readFileSync(outputFile));
reportportal.sendFileToTest(test, 'info', filename, fs.readFileSync(outputFile));
}

@@ -112,3 +114,3 @@ }

```js
const reporter = require('wdio-reportportal-reporter');
const reportportal = require('wdio-reportportal-reporter');

@@ -125,3 +127,3 @@ exports.config = {

let attachment = Buffer.from(screenShot, 'base64');
reporter.sendFileToTest(failureObject, 'error', "screnshot.png", attachment);
reportportal.sendFileToTest(failureObject, 'error', "screnshot.png", attachment);
}

@@ -128,0 +130,0 @@ }

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