Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-80662 || Browser parameter #37

Merged
merged 4 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' }],
},
tr1ble marked this conversation as resolved.
Show resolved Hide resolved
'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 } 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 @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down