Skip to content

Commit

Permalink
Merge pull request #66 from reportportal/develop
Browse files Browse the repository at this point in the history
Release 5.0.7
  • Loading branch information
AmsterGet authored Sep 15, 2022
2 parents c445036 + 536eabf commit 1e81c62
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 120 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
### Fixed
- Suites finishing algorithm bugfixes

## [5.0.6] - 2022-09-13
### Fixed
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ npm install --save-dev @reportportal/agent-js-playwright
```
## Reporting

When organizing tests, specify titles for `test.describe` blocks, as this is necessary to build the correct structure of reports.

It is also required to specify playwright project names in `playwright.config.ts` when running the same tests in different playwright projects.

### Attachments

Attachments can be easily added during test run via `testInfo.attachments` according to the Playwright [docs](https://playwright.dev/docs/api/class-testinfo#test-info-attachments).
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.6
5.0.7-SNAPSHOT
38 changes: 32 additions & 6 deletions src/__tests__/reporter/finishSuiteReporting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,22 @@ describe('finish report suite', () => {
reporter.launchId = 'tempLaunchId';

const testParams = {
title: 'test',
title: 'testTitle',
parent: {
title: suiteName,
title: rootSuite,
project: () => ({ name: rootSuite }),
allTests: () => [
{ title: 'testTitle', titlePath: () => ['', rootSuite, suiteName, 'testTitle'] },
],
parent: {
title: rootSuite,
project: () => ({ name: rootSuite }),
allTests: () => [
{ title: 'testTitle', titlePath: () => ['', rootSuite, suiteName, 'testTitle'] },
],
},
},
titlePath: () => [rootSuite, suiteName, 'testTitle'],
titlePath: () => ['', rootSuite, suiteName, 'testTitle'],
location: {
file: `C:${path.sep}testProject${path.sep}tests${path.sep}example.js`,
},
Expand All @@ -44,13 +54,29 @@ describe('finish report suite', () => {
};

reporter.testItems = new Map([
['tempTestItemId', { id: 'tempTestItemId', name: 'test', playwrightProjectName: rootSuite }],
[
'tempTestItemId',
{ id: 'tempTestItemId', name: 'testTitle', playwrightProjectName: rootSuite },
],
]);
reporter.suites = new Map([
[rootSuite, { id: 'rootsuiteId', name: rootSuite, rootSuiteLength: 1, rootSuite }],
[
rootSuite,
{
id: 'rootsuiteId',
name: rootSuite,
testCount: 1,
descendants: [`${rootSuite}/${suiteName}/testTitle`],
},
],
[
`${rootSuite}/${suiteName}`,
{ id: 'parentSuiteId', name: suiteName, testsLength: 1, rootSuite },
{
id: 'parentSuiteId',
name: suiteName,
testCount: 1,
descendants: [`${rootSuite}/${suiteName}/testTitle`],
},
],
]);

Expand Down
39 changes: 34 additions & 5 deletions src/__tests__/reporter/finishTestItemReporting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,30 @@ describe('finish test reporting', () => {
reporter.client = new RPClientMock(mockConfig);
reporter.launchId = 'tempLaunchId';
reporter.testItems = new Map([
['tempTestItemId', { id: 'tempTestItemId', name: 'test', playwrightProjectName: rootSuite }],
[
'tempTestItemId',
{ id: 'tempTestItemId', name: 'testTitle', playwrightProjectName: rootSuite },
],
]);
reporter.suites = new Map([
[rootSuite, { id: 'rootsuiteId', name: rootSuite, rootSuiteLength: 1, rootSuite }],
[`${rootSuite}/${suiteName}`, { id: 'suiteId', name: suiteName, testsLength: 1, rootSuite }],
[
rootSuite,
{
id: 'rootsuiteId',
name: rootSuite,
testCount: 1,
descendants: [`${rootSuite}/${suiteName}/testTitle`],
},
],
[
`${rootSuite}/${suiteName}`,
{
id: 'suiteId',
name: suiteName,
testCount: 1,
descendants: [`${rootSuite}/${suiteName}/testTitle`],
},
],
]);
const attributes = [
{
Expand All @@ -44,10 +63,20 @@ describe('finish test reporting', () => {
const description = 'description';

const testParams = {
title: 'test',
title: 'testTitle',
parent: {
title: suiteName,
title: rootSuite,
project: () => ({ name: rootSuite }),
allTests: () => [
{ title: 'testTitle', titlePath: () => ['', rootSuite, suiteName, 'testTitle'] },
],
parent: {
title: rootSuite,
project: () => ({ name: rootSuite }),
allTests: () => [
{ title: 'testTitle', titlePath: () => ['', rootSuite, suiteName, 'testTitle'] },
],
},
},
titlePath: () => [rootSuite, suiteName, 'testTitle'],
location: {
Expand Down
46 changes: 31 additions & 15 deletions src/__tests__/reporter/logReporting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,40 +91,56 @@ describe('logs reporting', () => {
[
playwrightProjectName,
{
id: tempTestItemId,
id: 'rootSuiteId',
name: playwrightProjectName,
testsLength: 0,
rootSuite: playwrightProjectName,
rootSuiteLength: 1,
testCount: 1,
descendants: [`${playwrightProjectName}/${suiteName}/testTitle`],
},
],
[
`${playwrightProjectName}/${suiteName}`,
{ id: 'suiteId', name: suiteName, testsLength: 1, rootSuite: playwrightProjectName },
{
id: 'suiteId',
name: suiteName,
testCount: 1,
descendants: [`${playwrightProjectName}/${suiteName}/testTitle`],
},
],
]);
reporter.testItems = new Map([
[tempTestItemId, { id: tempTestItemId, name: 'test', playwrightProjectName }],
[tempTestItemId, { id: tempTestItemId, name: 'testTitle', playwrightProjectName }],
]);
const testParams = {
title: 'test',
title: 'testTitle',
parent: {
title: playwrightProjectName,
location: 'tests/example.js',
tests: ['testTitle'],
project: () => ({ name: playwrightProjectName }),
allTests: () => [
{
title: 'testTitle',
titlePath: () => ['', playwrightProjectName, suiteName, 'testTitle'],
},
],
parent: {
title: suiteName,
location: 'tests/example.js',
project: () => ({ name: playwrightProjectName }),
allTests: () => [
{
title: 'testTitle',
titlePath: () => ['', playwrightProjectName, suiteName, 'testTitle'],
},
],
},
},
location: {
file: `C:${path.sep}testProject${path.sep}tests${path.sep}example.js`,
line: 5,
column: 3,
},
titlePath: () => [
'',
playwrightProjectName,
'tests/example.js',
'rootDescribe',
'parentDescribe',
'testTitle',
],
titlePath: () => ['', playwrightProjectName, suiteName, 'testTitle'],
};

const result = {
Expand Down
19 changes: 10 additions & 9 deletions src/__tests__/reporter/startSuiteTestReporting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ describe('start reporting suite/test', () => {
parent: {
title: suiteName,
location: 'tests/example.js',
tests: ['test'],
project: () => ({ name: '' }),
allTests: () => ['test'],
allTests: () => [
{ title: 'testTitle', titlePath: () => ['', rootSuite, suiteName, 'testTitle'] },
],
parent: {
title: rootSuite,
location: 'tests/example.js',
project: () => ({ name: '' }),
allTests: () => ['test'],
allTests: () => [
{ title: 'testTitle', titlePath: () => ['', rootSuite, suiteName, 'testTitle'] },
],
},
},
location: {
Expand All @@ -61,19 +64,17 @@ describe('start reporting suite/test', () => {
{
id: 'tempTestItemId',
name: rootSuite,
rootSuite,
rootSuiteLength: 1,
testsLength: 1,
testCount: 1,
descendants: [`${rootSuite}/${suiteName}/testTitle`],
},
],
[
`${rootSuite}/${suiteName}`,
{
id: 'tempTestItemId',
name: suiteName,
rootSuite,
rootSuiteLength: undefined,
testsLength: 1,
descendants: [`${rootSuite}/${suiteName}/testTitle`],
testCount: 1,
},
],
]);
Expand Down
18 changes: 0 additions & 18 deletions src/__tests__/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
getAttachments,
isErrorLog,
convertToRpStatus,
getTestFilePath,
} from '../utils';
import fs from 'fs';
import path from 'path';
Expand Down Expand Up @@ -287,21 +286,4 @@ describe('testing utils', () => {
expect(status).not.toBe(STATUSES.FAILED);
});
});
describe('getTestFilePath', () => {
test('getTestFilePath should return test file path string', () => {
const mockedTest = {
title: 'first',
location: {
file: `C:${path.sep}project${path.sep}tests${path.sep}simpleTest.spec.ts`,
},
titlePath: () => ['', 'project', 'tests/simpleTest.spec.ts', 'first'],
};

// @ts-ignore
const receivedValue = getTestFilePath(mockedTest, mockedTest.title);
const expectedValue = 'project/tests/simpleTest.spec.ts';

expect(receivedValue).toBe(expectedValue);
});
});
});
Loading

0 comments on commit 1e81c62

Please sign in to comment.