Skip to content

Commit

Permalink
Merge pull request #101 from reportportal/develop
Browse files Browse the repository at this point in the history
Release 5.1.0
  • Loading branch information
AmsterGet authored Jun 5, 2023
2 parents fac5db9 + 3d68d69 commit 2be9311
Show file tree
Hide file tree
Showing 16 changed files with 387 additions and 92 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### Added
- `launchId` option to the config to attach run results to an existing launch. Related to parallel execution on one and several machines [#86](https://github.com/reportportal/agent-js-playwright/issues/86).
- `uploadVideo` and `uploadTrace` options to the config to disable auto-attaching the Playwright's [video](https://playwright.dev/docs/api/class-testoptions#test-options-video) and [trace](https://playwright.dev/docs/api/class-testoptions#test-options-trace). Addressed [#98](https://github.com/reportportal/agent-js-playwright/issues/98).
### Changed
- `@reportportal/client-javascript` bumped to version `5.0.11`.

## [5.0.11] - 2023-04-13
### Fixed
Expand Down
41 changes: 25 additions & 16 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.11
5.0.12-SNAPSHOT
61 changes: 30 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test:coverage": "jest --coverage"
},
"dependencies": {
"@reportportal/client-javascript": "^5.0.8",
"@reportportal/client-javascript": "^5.0.11",
"strip-ansi": "6.0.1"
},
"files": [
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/mocks/RPClientMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import { ReportPortalConfig } from '../../models';

const mockedDate = Date.now();
export const mockedDate = Date.now();

export class RPClientMock {
private config: ReportPortalConfig;
Expand Down
132 changes: 117 additions & 15 deletions src/__tests__/reporter/launchesReporting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import { getSystemAttributes } from '../../utils';
import { LAUNCH_MODES } from '../../constants';

import { mockConfig } from '../mocks/configMock';
import { RPClientMock } from '../mocks/RPClientMock';
import { RPClientMock, mockedDate } from '../mocks/RPClientMock';

describe('start report launch', () => {
describe('start launch', () => {
describe('DEFAULT mode', () => {
const reporter = new RPReporter(mockConfig);
reporter.client = new RPClientMock(mockConfig);
const startLaunchObj: StartLaunchObjType = {
name: mockConfig.launch,
startTime: reporter.client.helpers.now(),
startTime: mockedDate,
attributes: getSystemAttributes(),
description: mockConfig.description,
mode: LAUNCH_MODES.DEFAULT,
Expand All @@ -56,15 +56,76 @@ describe('start report launch', () => {
reporter.client = new RPClientMock(customConfig);
const startLaunchObj: StartLaunchObjType = {
name: customConfig.launch,
startTime: reporter.client.helpers.now(),
startTime: mockedDate,
attributes: getSystemAttributes(),
description: customConfig.description,
mode: customConfig.mode,
};

beforeAll(() => reporter.onBegin());

test('should allow to pass mode to startLaunch', () => {
test('client.startLaunch should be called with corresponding params', () => {
expect(reporter.client.startLaunch).toHaveBeenCalledTimes(1);
expect(reporter.client.startLaunch).toHaveBeenCalledWith(startLaunchObj);
});

test('reporter.launchId should be set', () => {
expect(reporter.launchId).toEqual('tempLaunchId');
});
});

describe('with existing launch id in config', () => {
const customConfig = {
...mockConfig,
launchId: 'id',
};
const reporter = new RPReporter(customConfig);
reporter.client = new RPClientMock(customConfig);
const startLaunchObj: StartLaunchObjType = {
name: customConfig.launch,
startTime: mockedDate,
attributes: getSystemAttributes(),
description: customConfig.description,
mode: LAUNCH_MODES.DEFAULT,
id: 'id',
};

beforeAll(() => reporter.onBegin());

test('client.startLaunch should be called with corresponding params', () => {
expect(reporter.client.startLaunch).toHaveBeenCalledTimes(1);
expect(reporter.client.startLaunch).toHaveBeenCalledWith(startLaunchObj);
});

test('reporter.launchId should be set', () => {
expect(reporter.launchId).toEqual('tempLaunchId');
});
});

describe('with existing launch id provided by ENV variable', () => {
let reporter: RPReporter;
const startLaunchObj: StartLaunchObjType = {
name: mockConfig.launch,
startTime: mockedDate,
attributes: getSystemAttributes(),
description: mockConfig.description,
mode: LAUNCH_MODES.DEFAULT,
id: 'id',
};

beforeAll(() => {
process.env.RP_LAUNCH_ID = 'id';
reporter = new RPReporter(mockConfig);
reporter.client = new RPClientMock(mockConfig);

reporter.onBegin();
});

afterAll(() => {
delete process.env.RP_LAUNCH_ID;
});

test('client.startLaunch should be called with corresponding params', () => {
expect(reporter.client.startLaunch).toHaveBeenCalledTimes(1);
expect(reporter.client.startLaunch).toHaveBeenCalledWith(startLaunchObj);
});
Expand All @@ -75,18 +136,59 @@ describe('start report launch', () => {
});
});

describe('finish report launch', () => {
const reporter = new RPReporter(mockConfig);
reporter.client = new RPClientMock(mockConfig);
reporter.launchId = 'tempLaunchId';
describe('finish launch', () => {
describe('without existing launch id in config', () => {
const reporter = new RPReporter(mockConfig);
reporter.client = new RPClientMock(mockConfig);
reporter.launchId = 'tempLaunchId';

beforeAll(() => reporter.onEnd());

test('launch should be finished', () => {
expect(reporter.client.finishLaunch).toHaveBeenCalledTimes(1);
expect(reporter.client.finishLaunch).toHaveBeenCalledWith('tempLaunchId', {
endTime: mockedDate,
});
expect(reporter.isLaunchFinishSend).toBe(true);
});
});

describe('with existing launch id in config', () => {
const customConfig = {
...mockConfig,
launchId: 'id',
};
const reporter = new RPReporter(customConfig);
reporter.client = new RPClientMock(customConfig);
reporter.launchId = 'tempLaunchId';

beforeAll(() => reporter.onEnd());

beforeAll(() => reporter.onEnd());
test('launch finish request should not be sent', () => {
expect(reporter.client.finishLaunch).toHaveBeenCalledTimes(0);
expect(reporter.isLaunchFinishSend).toBe(true);
});
});

describe('with existing launch id provided by ENV variable', () => {
let reporter: RPReporter;

beforeAll(() => {
process.env.RP_LAUNCH_ID = 'id';
reporter = new RPReporter(mockConfig);
reporter.client = new RPClientMock(mockConfig);
reporter.launchId = 'tempLaunchId';

reporter.onEnd();
});

afterAll(() => {
delete process.env.RP_LAUNCH_ID;
});

test('launch should be finished', () => {
expect(reporter.client.finishLaunch).toHaveBeenCalledTimes(1);
expect(reporter.client.finishLaunch).toHaveBeenCalledWith('tempLaunchId', {
endTime: reporter.client.helpers.now(),
test('launch finish request should not be sent', () => {
expect(reporter.client.finishLaunch).toHaveBeenCalledTimes(0);
expect(reporter.isLaunchFinishSend).toBe(true);
});
expect(reporter.isLaunchFinishSend).toBe(true);
});
});
Loading

0 comments on commit 2be9311

Please sign in to comment.