wdio-reportportal-reporter
Advanced tools
Comparing version 6.4.1 to 6.4.2
@@ -0,0 +0,0 @@ ## Proposed changes |
@@ -46,6 +46,7 @@ export declare enum EVENTS { | ||
} | ||
export declare enum CUCUMBER_STATUS { | ||
export declare enum WDIO_TEST_STATUS { | ||
PASSED = "passed", | ||
FAILED = "failed", | ||
SKIPPED = "skipped" | ||
SKIPPED = "skipped", | ||
PENDING = "pending" | ||
} | ||
@@ -52,0 +53,0 @@ export declare enum MODE { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MODE = exports.CUCUMBER_STATUS = exports.CUCUMBER_TYPE = exports.TYPE = exports.LEVEL = exports.STATUS = exports.EVENTS = void 0; | ||
exports.MODE = exports.WDIO_TEST_STATUS = exports.CUCUMBER_TYPE = exports.TYPE = exports.LEVEL = exports.STATUS = exports.EVENTS = void 0; | ||
var EVENTS; | ||
@@ -54,8 +54,9 @@ (function (EVENTS) { | ||
})(CUCUMBER_TYPE = exports.CUCUMBER_TYPE || (exports.CUCUMBER_TYPE = {})); | ||
var CUCUMBER_STATUS; | ||
(function (CUCUMBER_STATUS) { | ||
CUCUMBER_STATUS["PASSED"] = "passed"; | ||
CUCUMBER_STATUS["FAILED"] = "failed"; | ||
CUCUMBER_STATUS["SKIPPED"] = "skipped"; | ||
})(CUCUMBER_STATUS = exports.CUCUMBER_STATUS || (exports.CUCUMBER_STATUS = {})); | ||
var WDIO_TEST_STATUS; | ||
(function (WDIO_TEST_STATUS) { | ||
WDIO_TEST_STATUS["PASSED"] = "passed"; | ||
WDIO_TEST_STATUS["FAILED"] = "failed"; | ||
WDIO_TEST_STATUS["SKIPPED"] = "skipped"; | ||
WDIO_TEST_STATUS["PENDING"] = "pending"; | ||
})(WDIO_TEST_STATUS = exports.WDIO_TEST_STATUS || (exports.WDIO_TEST_STATUS = {})); | ||
var MODE; | ||
@@ -62,0 +63,0 @@ (function (MODE) { |
@@ -0,0 +0,0 @@ import { STATUS, TYPE } from "./constants"; |
@@ -0,0 +0,0 @@ "use strict"; |
import Reporter from "@wdio/reporter"; | ||
import * as ReportPortalClient from "reportportal-js-client"; | ||
import { LEVEL, STATUS, TYPE } from "./constants"; | ||
@@ -38,3 +37,3 @@ import { Issue } from "./entities"; | ||
testFinished(test: any, status: STATUS, issue?: Issue): void; | ||
onRunnerStart(runner: any, client: ReportPortalClient): void; | ||
onRunnerStart(runner: any): void; | ||
onRunnerEnd(): Promise<any>; | ||
@@ -45,2 +44,3 @@ onBeforeCommand(command: any): void; | ||
onHookEnd(hook: any): void; | ||
private getReportPortalClient; | ||
private addAttribute; | ||
@@ -47,0 +47,0 @@ private finishTestManually; |
@@ -123,13 +123,14 @@ "use strict"; | ||
log.debug(`End suite ${suite.title} ${suite.uid}`); | ||
let status = constants_1.STATUS.PASSED; | ||
const isSomeTestFailed = suite.tests.some(({ state }) => state === constants_1.WDIO_TEST_STATUS.FAILED); | ||
let suiteStatus = isSomeTestFailed ? constants_1.STATUS.FAILED : constants_1.STATUS.PASSED; | ||
if (this.options.cucumberNestedSteps) { | ||
switch (suite.type) { | ||
case constants_1.CUCUMBER_TYPE.SCENARIO: | ||
const scenarioStepsAllPassed = suite.tests.every(({ state }) => state === constants_1.CUCUMBER_STATUS.PASSED); | ||
const scenarioStepsAllSkipped = suite.tests.every(({ state }) => state === constants_1.CUCUMBER_STATUS.SKIPPED); | ||
status = scenarioStepsAllPassed ? constants_1.STATUS.PASSED : scenarioStepsAllSkipped ? constants_1.STATUS.SKIPPED : 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; | ||
const scenarioStepsAllPassed = suite.tests.every(({ state }) => state === constants_1.WDIO_TEST_STATUS.PASSED); | ||
const scenarioStepsAllSkipped = suite.tests.every(({ state }) => state === constants_1.WDIO_TEST_STATUS.SKIPPED); | ||
suiteStatus = scenarioStepsAllPassed ? constants_1.STATUS.PASSED : scenarioStepsAllSkipped ? constants_1.STATUS.SKIPPED : constants_1.STATUS.FAILED; | ||
this.featureStatus = this.featureStatus === constants_1.STATUS.PASSED && suiteStatus === constants_1.STATUS.PASSED ? constants_1.STATUS.PASSED : constants_1.STATUS.FAILED; | ||
break; | ||
case constants_1.CUCUMBER_TYPE.FEATURE: | ||
status = this.featureStatus; | ||
suiteStatus = this.featureStatus; | ||
break; | ||
@@ -139,3 +140,3 @@ } | ||
const suiteItem = this.storage.getCurrentSuite(); | ||
const finishSuiteObj = { status }; | ||
const finishSuiteObj = { status: suiteStatus }; | ||
const { promise } = this.client.finishTestItem(suiteItem.id, finishSuiteObj); | ||
@@ -217,4 +218,3 @@ utils_1.promiseErrorHandler(promise); | ||
} | ||
// @ts-ignore | ||
onRunnerStart(runner, client) { | ||
onRunnerStart(runner) { | ||
log.debug(`Runner start`); | ||
@@ -226,3 +226,3 @@ this.rpPromisesCompleted = false; | ||
this.isCucumberFramework = runner.config.framework === 'cucumber'; | ||
this.client = client || new ReportPortalClient(this.options.reportPortalClientConfig); | ||
this.client = this.getReportPortalClient(); | ||
this.launchId = process.env.RP_LAUNCH_ID; | ||
@@ -306,2 +306,5 @@ this.specFilePath = runner.specs[0] || ""; | ||
} | ||
getReportPortalClient() { | ||
return new ReportPortalClient(this.options.reportPortalClientConfig); | ||
} | ||
addAttribute(attribute) { | ||
@@ -308,0 +311,0 @@ this.currentTestAttributes.push(Object.assign({}, attribute)); |
@@ -0,0 +0,0 @@ import { LEVEL, MODE } from "./constants"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { StorageEntity } from "./entities"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { StartTestItem } from "./entities"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import {LEVEL} from "../constants"; |
@@ -1,2 +0,2 @@ | ||
import {CUCUMBER_STATUS, CUCUMBER_TYPE, STATUS} from "../constants"; | ||
import {WDIO_TEST_STATUS, CUCUMBER_TYPE, STATUS} from "../constants"; | ||
import {suiteEndEvent, suiteStartEvent} from "./fixtures/events"; | ||
@@ -17,3 +17,3 @@ import {getDefaultOptions, RPClientMock} from "./reportportal-client.mock"; | ||
test("should endSuite", () => { | ||
test("should endSuite as passed", () => { | ||
const {id} = reporter.storage.getCurrentSuite(); | ||
@@ -29,2 +29,24 @@ reporter.onSuiteEnd(suiteEndEvent()); | ||
test("should set status as failing if there are failed tests", () => { | ||
const {id} = reporter.storage.getCurrentSuite(); | ||
reporter.onSuiteEnd(Object.assign( | ||
suiteEndEvent(), | ||
{ | ||
tests: [ | ||
{ | ||
state: WDIO_TEST_STATUS.FAILED, | ||
}, | ||
{ | ||
state: WDIO_TEST_STATUS.PASSED, | ||
}, | ||
] | ||
})); | ||
expect(reporter.client.finishTestItem).toBeCalledWith( | ||
id, | ||
{status: STATUS.FAILED}, | ||
); | ||
}); | ||
test("should set status as passing for cucumber nested steps", () => { | ||
@@ -38,6 +60,6 @@ Object.assign(reporter.options, {cucumberNestedSteps: true}); | ||
{ | ||
state: CUCUMBER_STATUS.PASSED, | ||
state: WDIO_TEST_STATUS.PASSED, | ||
}, | ||
{ | ||
state: CUCUMBER_STATUS.PASSED, | ||
state: WDIO_TEST_STATUS.PASSED, | ||
}, | ||
@@ -62,6 +84,6 @@ ], | ||
{ | ||
state: CUCUMBER_STATUS.FAILED, | ||
state: WDIO_TEST_STATUS.FAILED, | ||
}, | ||
{ | ||
state: CUCUMBER_STATUS.PASSED, | ||
state: WDIO_TEST_STATUS.PASSED, | ||
}, | ||
@@ -68,0 +90,0 @@ ], |
@@ -0,0 +0,0 @@ import {getDefaultOptions, RPClientMock} from "./reportportal-client.mock"; |
@@ -1,3 +0,26 @@ | ||
export const suiteStartEvent = () => ({uid: "FooBarSuite", cid: "0-0", title: "foo", runner: {"0-0": {}}}); | ||
export const suiteEndEvent = () => ({uid: "FooBarSuite", cid: "0-0", title: "foo"}); | ||
export const testStartEvent = () => ({uid: "FooBarTest", fullTitle: "fullTitle", type: 'test', cid: "0-0", title: "foo", runner: {"0-0": {}}}); | ||
import {WDIO_TEST_STATUS} from "../../constants"; | ||
export const suiteStartEvent = () => ({ | ||
uid: "FooBarSuite", | ||
cid: "0-0", | ||
title: "foo", | ||
runner: {"0-0": {}} | ||
}); | ||
export const suiteEndEvent = () => ({ | ||
uid: "FooBarSuite", | ||
cid: "0-0", | ||
title: "foo", | ||
tests: [{ | ||
state: WDIO_TEST_STATUS.PASSED, | ||
}] | ||
}); | ||
export const testStartEvent = () => ({ | ||
uid: "FooBarTest", | ||
fullTitle: "fullTitle", | ||
type: 'test', | ||
cid: "0-0", | ||
title: "foo", | ||
runner: {"0-0": {}} | ||
}); |
@@ -0,0 +0,0 @@ import ReporterOptions from "../ReporterOptions"; |
@@ -17,7 +17,8 @@ import {Attribute} from "../../build/ReporterOptions"; | ||
const reporter = new Reporter(options); | ||
const client = new RPClientMock(); | ||
process.env.RP_LAUNCH_ID = REAL_LAUNCH_ID; | ||
reporter.onRunnerStart(runnerStat, client); | ||
jest.spyOn(reporter, 'getReportPortalClient').mockImplementation(() => new RPClientMock()); | ||
reporter.onRunnerStart(runnerStat); | ||
expect(reporter.tempLaunchId).toEqual("startLaunch"); | ||
@@ -44,6 +45,6 @@ expect(reporter.launchId).toEqual(REAL_LAUNCH_ID); | ||
const reporter = new Reporter(options); | ||
const client = new RPClientMock(); | ||
process.env.RP_LAUNCH_ID = REAL_LAUNCH_ID; | ||
reporter.onRunnerStart(runnerStat, client); | ||
jest.spyOn(reporter, 'getReportPortalClient').mockImplementation(() => new RPClientMock()); | ||
reporter.onRunnerStart(runnerStat); | ||
@@ -50,0 +51,0 @@ expect(reporter.tempLaunchId).toEqual("startLaunch"); |
@@ -0,0 +0,0 @@ import {CUCUMBER_TYPE, TYPE} from "../constants"; |
@@ -0,0 +0,0 @@ import {CUCUMBER_TYPE, TYPE} from "../constants"; |
@@ -0,0 +0,0 @@ import {TYPE} from "../constants"; |
@@ -0,0 +0,0 @@ import {TYPE} from "../constants"; |
@@ -51,6 +51,7 @@ export enum EVENTS { | ||
export enum CUCUMBER_STATUS { | ||
export enum WDIO_TEST_STATUS { | ||
PASSED = "passed", | ||
FAILED = "failed", | ||
SKIPPED = "skipped" | ||
SKIPPED = "skipped", | ||
PENDING = "pending" | ||
} | ||
@@ -57,0 +58,0 @@ |
@@ -0,0 +0,0 @@ import {STATUS, TYPE} from "./constants"; |
@@ -6,3 +6,3 @@ import logger from "@wdio/logger"; | ||
import * as ReportPortalClient from "reportportal-js-client"; | ||
import {CUCUMBER_STATUS, CUCUMBER_TYPE, EVENTS, LEVEL, STATUS, TYPE} from "./constants"; | ||
import {WDIO_TEST_STATUS, CUCUMBER_TYPE, EVENTS, LEVEL, STATUS, TYPE} from "./constants"; | ||
import {EndTestItem, Issue, StartTestItem, StorageEntity} from "./entities"; | ||
@@ -158,13 +158,14 @@ import ReporterOptions, {Attribute} from "./ReporterOptions"; | ||
let status = STATUS.PASSED; | ||
const isSomeTestFailed = suite.tests.some(({ state }) => state === WDIO_TEST_STATUS.FAILED); | ||
let suiteStatus = isSomeTestFailed ? STATUS.FAILED : STATUS.PASSED; | ||
if (this.options.cucumberNestedSteps) { | ||
switch (suite.type) { | ||
case CUCUMBER_TYPE.SCENARIO: | ||
const scenarioStepsAllPassed = suite.tests.every(({state}) => state === CUCUMBER_STATUS.PASSED); | ||
const scenarioStepsAllSkipped = suite.tests.every(({ state }) => state === CUCUMBER_STATUS.SKIPPED); | ||
status = scenarioStepsAllPassed ? STATUS.PASSED : scenarioStepsAllSkipped ? STATUS.SKIPPED : STATUS.FAILED; | ||
this.featureStatus = this.featureStatus === STATUS.PASSED && status === STATUS.PASSED ? STATUS.PASSED : STATUS.FAILED; | ||
const scenarioStepsAllPassed = suite.tests.every(({state}) => state === WDIO_TEST_STATUS.PASSED); | ||
const scenarioStepsAllSkipped = suite.tests.every(({ state }) => state === WDIO_TEST_STATUS.SKIPPED); | ||
suiteStatus = scenarioStepsAllPassed ? STATUS.PASSED : scenarioStepsAllSkipped ? STATUS.SKIPPED : STATUS.FAILED; | ||
this.featureStatus = this.featureStatus === STATUS.PASSED && suiteStatus === STATUS.PASSED ? STATUS.PASSED : STATUS.FAILED; | ||
break; | ||
case CUCUMBER_TYPE.FEATURE: | ||
status = this.featureStatus; | ||
suiteStatus = this.featureStatus; | ||
break; | ||
@@ -175,3 +176,3 @@ } | ||
const suiteItem = this.storage.getCurrentSuite(); | ||
const finishSuiteObj = {status}; | ||
const finishSuiteObj = {status: suiteStatus}; | ||
const {promise} = this.client.finishTestItem(suiteItem.id, finishSuiteObj); | ||
@@ -264,4 +265,3 @@ promiseErrorHandler(promise); | ||
// @ts-ignore | ||
onRunnerStart(runner, client: ReportPortalClient) { | ||
onRunnerStart(runner) { | ||
log.debug(`Runner start`); | ||
@@ -273,3 +273,3 @@ this.rpPromisesCompleted = false; | ||
this.isCucumberFramework = runner.config.framework === 'cucumber' | ||
this.client = client || new ReportPortalClient(this.options.reportPortalClientConfig); | ||
this.client = this.getReportPortalClient(); | ||
this.launchId = process.env.RP_LAUNCH_ID; | ||
@@ -356,2 +356,6 @@ this.specFilePath = runner.specs[0] || ""; | ||
private getReportPortalClient(): ReportPortalClient{ | ||
return new ReportPortalClient(this.options.reportPortalClientConfig); | ||
} | ||
private addAttribute(attribute: Attribute) { | ||
@@ -358,0 +362,0 @@ this.currentTestAttributes.push({...attribute}) |
@@ -0,0 +0,0 @@ import {LEVEL, MODE} from "./constants"; |
@@ -0,0 +0,0 @@ import {StorageEntity} from "./entities"; |
@@ -0,0 +0,0 @@ // @ts-ignore |
{ | ||
"name": "wdio-reportportal-reporter", | ||
"version": "6.4.1", | ||
"version": "6.4.2", | ||
"description": "A WebdriverIO v6 plugin. Report results to Report Portal.", | ||
@@ -5,0 +5,0 @@ "main": "build/reporter.js", |
@@ -0,0 +0,0 @@ WDIO Report Portal Reporter |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2260
95610