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

Release 5.1.1 #150

Merged
merged 9 commits into from
Nov 1, 2024
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
15 changes: 14 additions & 1 deletion .github/workflows/CI-pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2024 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.

name: CI-pipeline

on:
Expand All @@ -19,7 +32,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
- name: Install of node dependencies
run: npm install
- name: Run lint
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2024 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.

name: publish

on:
Expand All @@ -13,7 +26,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
- name: Install of node dependencies
run: npm install
- name: Run lint
Expand All @@ -30,7 +43,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
registry-url: 'https://registry.npmjs.org'
- name: Install of node dependencies
run: npm install
Expand All @@ -44,7 +57,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
registry-url: 'https://npm.pkg.github.com'
scope: '@reportportal'
- name: Publish to GPR
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2024 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.

name: release

on:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
### Fixed
- Race condition when many suites run in parallel. Resolves [#147](https://github.com/reportportal/agent-js-jest/issues/147). Thanks to [@tristanzander](https://github.com/tristanzander).

## [5.1.0] - 2024-07-11
### Added
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ Read more about [retries in jest](https://jestjs.io/ru/docs/jest-object#jestretr

This reporter provides `ReportingApi` in global variables to use it directly in tests to send some additional data to the report.

*Note:* `ReportingApi` does not support tests running in [`concurrent` mode](https://jestjs.io/docs/api#testconcurrentname-fn-timeout) at the moment.
*Note:* Run with the default test files concurrency may lead to inconsistent files attaching. `ReportingApi` also does not support tests running in [`concurrent` mode](https://jestjs.io/docs/api#testconcurrentname-fn-timeout) at the moment.

We are going to fix this behavior in the future.

### Reporting API methods

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.1.0
5.1.1-SNAPSHOT
48 changes: 38 additions & 10 deletions __tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const systemAttr = {
};

describe('index script', () => {
/**
* @type {JestReportPortal}
*/
let reporter;

beforeAll(() => {
Expand Down Expand Up @@ -371,7 +374,14 @@ describe('index script', () => {
const spyFinishFailedTest = jest.spyOn(reporter, '_finishFailedStep');
const spyFinishSkippedTest = jest.spyOn(reporter, '_finishSkippedStep');

reporter._finishStep({ status: TEST_ITEM_STATUSES.PASSED, failureMessages: [] });
reporter.tempStepIds.set('/fake test', 'tempStepId');

reporter._finishStep({
status: TEST_ITEM_STATUSES.PASSED,
failureMessages: [],
ancestorTitles: [],
title: 'fake test',
});

expect(spyFinishPassedTest).toHaveBeenCalled();
expect(spyFinishFailedTest).not.toHaveBeenCalled();
Expand All @@ -383,12 +393,19 @@ describe('index script', () => {
const spyFinishFailedTest = jest.spyOn(reporter, '_finishFailedStep');
const spyFinishSkippedTest = jest.spyOn(reporter, '_finishSkippedStep');

reporter.tempStepIds.set('/fake test', 'tempStepId');

reporter._finishStep(
{ status: TEST_ITEM_STATUSES.FAILED, failureMessages: ['error message'] },
{
status: TEST_ITEM_STATUSES.FAILED,
failureMessages: ['error message'],
ancestorTitles: [],
title: 'fake test',
},
false,
);

expect(spyFinishFailedTest).toHaveBeenCalledWith('error message');
expect(spyFinishFailedTest).toHaveBeenCalledWith('tempStepId', 'error message');
expect(spyFinishPassedTest).not.toHaveBeenCalled();
expect(spyFinishSkippedTest).not.toHaveBeenCalled();
});
Expand All @@ -398,7 +415,14 @@ describe('index script', () => {
const spyFinishFailedTest = jest.spyOn(reporter, '_finishFailedStep');
const spyFinishSkippedTest = jest.spyOn(reporter, '_finishSkippedStep');

reporter._finishStep({ status: TEST_ITEM_STATUSES.SKIPPED, failureMessages: [] });
reporter.tempStepIds.set('/fake test', 'tempStepId');

reporter._finishStep({
status: TEST_ITEM_STATUSES.SKIPPED,
failureMessages: [],
ancestorTitles: [],
title: 'fake test',
});

expect(spyFinishSkippedTest).toHaveBeenCalled();
expect(spyFinishPassedTest).not.toHaveBeenCalled();
Expand Down Expand Up @@ -447,7 +471,7 @@ describe('index script', () => {
};
reporter.tempStepId = 'tempStepId';

reporter._finishPassedStep(false);
reporter._finishPassedStep('tempStepId', false);

expect(reporter.client.finishTestItem).toHaveBeenCalledWith(
'tempStepId',
Expand All @@ -467,9 +491,13 @@ describe('index script', () => {
};
reporter.tempStepId = tempStepId;

reporter._finishFailedStep(errorMessage, false);
reporter._finishFailedStep('tempStepId', errorMessage, false);

expect(spySendLog).toHaveBeenCalledWith({ message: errorMessage, level: LOG_LEVEL.ERROR });
expect(spySendLog).toHaveBeenCalledWith({
message: errorMessage,
level: LOG_LEVEL.ERROR,
tempStepId: 'tempStepId',
});
expect(reporter.client.finishTestItem).toHaveBeenCalledWith(
tempStepId,
expectedFinishTestItemParameter,
Expand All @@ -486,7 +514,7 @@ describe('index script', () => {
reporter.tempStepId = 'tempStepId';
reporter.reportOptions.extendTestDescriptionWithLastError = false;

reporter._finishFailedStep('error message', false);
reporter._finishFailedStep('tempStepId', 'error message', false);

expect(reporter.client.finishTestItem).toHaveBeenCalledWith(
'tempStepId',
Expand All @@ -503,7 +531,7 @@ describe('index script', () => {
};
reporter.tempStepId = 'tempStepId';

reporter._finishSkippedStep(false);
reporter._finishSkippedStep('tempStepId', false);

expect(reporter.client.finishTestItem).toHaveBeenCalledWith(
'tempStepId',
Expand All @@ -519,7 +547,7 @@ describe('index script', () => {
reporter.tempStepId = 'tempStepId';
reporter.reportOptions.skippedIssue = false;

reporter._finishSkippedStep(false);
reporter._finishSkippedStep('tempStepId', false);

expect(reporter.client.finishTestItem).toHaveBeenCalledWith(
'tempStepId',
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
module.exports = {
moduleFileExtensions: ['js'],
testRegex: '/__tests__/.*\\.spec.(js)$',
collectCoverageFrom: ['./utils/**', './index.js'],
collectCoverageFrom: ['src/**'],
coverageThreshold: {
global: {
branches: 80,
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

32 changes: 20 additions & 12 deletions src/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,46 +201,54 @@ class JestReportPortal {
_finishStep(test) {
const errorMsg = test.failureMessages[0];

const fullName = getFullStepName(test);
const tempStepId = this.tempStepIds.get(fullName);

if (tempStepId === undefined) {
console.error(`Could not finish Test Step - "${fullName}". tempId not found`);
return;
}

switch (test.status) {
case TEST_ITEM_STATUSES.PASSED:
this._finishPassedStep();
this._finishPassedStep(tempStepId);
break;
case TEST_ITEM_STATUSES.FAILED:
this._finishFailedStep(errorMsg);
this._finishFailedStep(tempStepId, errorMsg);
break;
default:
this._finishSkippedStep();
this._finishSkippedStep(tempStepId);
}
}

_finishPassedStep() {
_finishPassedStep(tempStepId) {
const status = TEST_ITEM_STATUSES.PASSED;
const { promise } = this.client.finishTestItem(this.tempStepId, { status });
const { promise } = this.client.finishTestItem(tempStepId, { status });

promiseErrorHandler(promise);
this.promises.push(promise);
}

_finishFailedStep(failureMessage) {
_finishFailedStep(tempStepId, failureMessage) {
const status = TEST_ITEM_STATUSES.FAILED;
const description =
this.reportOptions.extendTestDescriptionWithLastError === false
? null
: `\`\`\`error\n${stripAnsi(failureMessage)}\n\`\`\``;
const finishTestObj = { status, ...(description && { description }) };

this.sendLog({ message: failureMessage, level: LOG_LEVEL.ERROR });
this.sendLog({ message: failureMessage, level: LOG_LEVEL.ERROR, tempStepId });

const { promise } = this.client.finishTestItem(this.tempStepId, finishTestObj);
const { promise } = this.client.finishTestItem(tempStepId, finishTestObj);

promiseErrorHandler(promise);
this.promises.push(promise);
}

sendLog({ level = LOG_LEVEL.INFO, message = '', file, time }) {
sendLog({ level = LOG_LEVEL.INFO, message = '', file, time, tempStepId }) {
const newMessage = stripAnsi(message);
const { promise } = this.client.sendLog(
this.tempStepId,
tempStepId === undefined ? this.tempStepId : tempStepId,
{
message: newMessage,
level,
Expand All @@ -253,14 +261,14 @@ class JestReportPortal {
this.promises.push(promise);
}

_finishSkippedStep() {
_finishSkippedStep(tempStepId) {
const status = 'skipped';
const issue = this.reportOptions.skippedIssue === false ? { issueType: 'NOT_ISSUE' } : null;
const finishTestObj = {
status,
...(issue && { issue }),
};
const { promise } = this.client.finishTestItem(this.tempStepId, finishTestObj);
const { promise } = this.client.finishTestItem(tempStepId, finishTestObj);

promiseErrorHandler(promise);
this.promises.push(promise);
Expand Down
2 changes: 1 addition & 1 deletion version_fragment
Original file line number Diff line number Diff line change
@@ -1 +1 @@
minor
patch