Skip to content

Commit

Permalink
Merge branch 'EPMRPP-80662_Browser_parameters' into EPMRPP-80543_Para…
Browse files Browse the repository at this point in the history
…meters

# Conflicts:
#	src/reporter.ts
  • Loading branch information
tr1ble committed Nov 10, 2022
2 parents d39dbeb + 57c2039 commit bc23c2a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/__tests__/onTestStart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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,
);
Expand Down
1 change: 1 addition & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
18 changes: 18 additions & 0 deletions src/constants/parameters.ts
Original file line number Diff line number Diff line change
@@ -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';
14 changes: 13 additions & 1 deletion src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, Parameter } from './models';

export class Reporter extends WDIOReporter {
Expand All @@ -46,6 +53,7 @@ export class Reporter extends WDIOReporter {
private syncReporting: boolean;
private testFilePath: string;
private isMultiremote: boolean;
private sanitizedCapabilities: string;

constructor(options: Partial<Reporters.Options>) {
super(options);
Expand Down Expand Up @@ -93,6 +101,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;
}
Expand Down Expand Up @@ -138,6 +147,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,
Expand Down

0 comments on commit bc23c2a

Please sign in to comment.