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 3 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
6 changes: 6 additions & 0 deletions src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import {
import { CUCUMBER_TYPE, FILE_TYPES, LOG_LEVELS, RP_STATUSES, TYPES } from './constants';
import { Attribute, FinishTestItem, LaunchObj, LogRQ, StartTestItem } from './models';

const BROWSER_PARAM = 'browser';
tr1ble marked this conversation as resolved.
Show resolved Hide resolved

export class Reporter extends WDIOReporter {
private client: RPClient;
private tempLaunchId: string;
Expand All @@ -46,6 +48,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 +96,7 @@ export class Reporter extends WDIOReporter {
this.isMultiremote = runnerStats.isMultiremote;
promiseErrorHandler(promise);
this.tempLaunchId = tempId;
this.sanitizedCapabilities = runnerStats.sanitizedCapabilities;
tr1ble marked this conversation as resolved.
Show resolved Hide resolved
}

onSuiteStart(suiteStats: SuiteStats): void {
Expand Down Expand Up @@ -131,11 +135,13 @@ export class Reporter extends WDIOReporter {
const { title: name } = testStats;
const ancestors = this.storage.getAllSuites();
const codeRef = getCodeRef(this.testFilePath, name, ancestors);
const browser = this.sanitizedCapabilities;
const testItemDataRQ = {
name,
type: TYPES.STEP,
codeRef,
...(this.options.cucumberNestedSteps && { hasStats: false }),
parameters: browser && [{ key: BROWSER_PARAM, value: browser }],
tr1ble marked this conversation as resolved.
Show resolved Hide resolved
};
const { tempId, promise } = this.client.startTestItem(
testItemDataRQ,
Expand Down