diff --git a/src/__tests__/onTestStart.spec.ts b/src/__tests__/onTestStart.spec.ts index 87330c6..08cafbf 100644 --- a/src/__tests__/onTestStart.spec.ts +++ b/src/__tests__/onTestStart.spec.ts @@ -28,6 +28,7 @@ describe('onTestStart', () => { reporter['tempLaunchId'] = 'tempLaunchId'; reporter['testFilePath'] = `C:${path.sep}project${path.sep}__test__${path.sep}example.js`; reporter['storage'].addSuite({ id: suiteId, name: suiteName }); + reporter['sanitizedCapabilities'] = 'chrome'; jest.spyOn(process, 'cwd').mockReturnValue(`C:${path.sep}project`); it('client.startTestItem should be called with corresponding params', () => { @@ -38,7 +39,12 @@ describe('onTestStart', () => { expect(reporter['client'].startTestItem).toBeCalledTimes(1); expect(reporter['client'].startTestItem).toBeCalledWith( - { name: testName, type: 'STEP', codeRef: '__test__/example.js/suite_name/test_name' }, + { + name: testName, + type: 'STEP', + codeRef: '__test__/example.js/suite_name/test_name', + parameters: [{ key: 'browser', value: 'chrome' }], + }, 'tempLaunchId', suiteId, ); diff --git a/src/constants/index.ts b/src/constants/index.ts index 49c72bd..5e6a7d9 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -19,3 +19,4 @@ export { CUCUMBER_TYPE, TYPES } from './testItemTypes'; export { RP_STATUSES } from './statuses'; export { LOG_LEVELS } from './logLevels'; export { FILE_TYPES } from './fileTypes'; +export { BROWSER_PARAM } from './parameters'; diff --git a/src/constants/parameters.ts b/src/constants/parameters.ts new file mode 100644 index 0000000..e8a924c --- /dev/null +++ b/src/constants/parameters.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2022 EPAM Systems + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +export const BROWSER_PARAM = 'browser'; diff --git a/src/reporter.ts b/src/reporter.ts index 924621e..fb08254 100644 --- a/src/reporter.ts +++ b/src/reporter.ts @@ -35,7 +35,14 @@ import { parseTags, promiseErrorHandler, } from './utils'; -import { CUCUMBER_TYPE, FILE_TYPES, LOG_LEVELS, RP_STATUSES, TYPES } from './constants'; +import { + CUCUMBER_TYPE, + FILE_TYPES, + LOG_LEVELS, + RP_STATUSES, + TYPES, + BROWSER_PARAM, +} from './constants'; import { Attribute, FinishTestItem, LaunchObj, LogRQ, StartTestItem } from './models'; export class Reporter extends WDIOReporter { @@ -46,6 +53,7 @@ export class Reporter extends WDIOReporter { private syncReporting: boolean; private testFilePath: string; private isMultiremote: boolean; + private sanitizedCapabilities: string; constructor(options: Partial) { super(options); @@ -91,6 +99,7 @@ export class Reporter extends WDIOReporter { const launchDataRQ: LaunchObj = getStartLaunchObj(this.options); const { tempId, promise } = this.client.startLaunch(launchDataRQ); this.isMultiremote = runnerStats.isMultiremote; + this.sanitizedCapabilities = runnerStats.sanitizedCapabilities; promiseErrorHandler(promise); this.tempLaunchId = tempId; } @@ -136,6 +145,9 @@ export class Reporter extends WDIOReporter { type: TYPES.STEP, codeRef, ...(this.options.cucumberNestedSteps && { hasStats: false }), + ...(this.sanitizedCapabilities && { + parameters: [{ key: BROWSER_PARAM, value: this.sanitizedCapabilities }], + }), }; const { tempId, promise } = this.client.startTestItem( testItemDataRQ,