Skip to content

Commit 371bcb2

Browse files
authored
Merge pull request #150 from reportportal/develop
Release 5.1.1
2 parents 9a18bce + 976f0ad commit 371bcb2

11 files changed

+110
-31
lines changed

.github/workflows/CI-pipeline.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Copyright 2024 EPAM Systems
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
114
name: CI-pipeline
215

316
on:
@@ -19,7 +32,7 @@ jobs:
1932
- name: Set up Node.js
2033
uses: actions/setup-node@v4
2134
with:
22-
node-version: 18
35+
node-version: 20
2336
- name: Install of node dependencies
2437
run: npm install
2538
- name: Run lint

.github/workflows/publish.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Copyright 2024 EPAM Systems
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
114
name: publish
215

316
on:
@@ -13,7 +26,7 @@ jobs:
1326
- name: Set up Node.js
1427
uses: actions/setup-node@v4
1528
with:
16-
node-version: 18
29+
node-version: 20
1730
- name: Install of node dependencies
1831
run: npm install
1932
- name: Run lint
@@ -30,7 +43,7 @@ jobs:
3043
- name: Set up Node.js
3144
uses: actions/setup-node@v4
3245
with:
33-
node-version: 18
46+
node-version: 20
3447
registry-url: 'https://registry.npmjs.org'
3548
- name: Install of node dependencies
3649
run: npm install
@@ -44,7 +57,7 @@ jobs:
4457
- name: Set up Node.js
4558
uses: actions/setup-node@v4
4659
with:
47-
node-version: 18
60+
node-version: 20
4861
registry-url: 'https://npm.pkg.github.com'
4962
scope: '@reportportal'
5063
- name: Publish to GPR

.github/workflows/release.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Copyright 2024 EPAM Systems
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
114
name: release
215

316
on:

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
### Fixed
2+
- 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).
13

24
## [5.1.0] - 2024-07-11
35
### Added

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ Read more about [retries in jest](https://jestjs.io/ru/docs/jest-object#jestretr
133133

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

136-
*Note:* `ReportingApi` does not support tests running in [`concurrent` mode](https://jestjs.io/docs/api#testconcurrentname-fn-timeout) at the moment.
136+
*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.
137+
138+
We are going to fix this behavior in the future.
137139

138140
### Reporting API methods
139141

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.1.0
1+
5.1.1-SNAPSHOT

__tests__/index.spec.js

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ const systemAttr = {
4040
};
4141

4242
describe('index script', () => {
43+
/**
44+
* @type {JestReportPortal}
45+
*/
4346
let reporter;
4447

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

374-
reporter._finishStep({ status: TEST_ITEM_STATUSES.PASSED, failureMessages: [] });
377+
reporter.tempStepIds.set('/fake test', 'tempStepId');
378+
379+
reporter._finishStep({
380+
status: TEST_ITEM_STATUSES.PASSED,
381+
failureMessages: [],
382+
ancestorTitles: [],
383+
title: 'fake test',
384+
});
375385

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

396+
reporter.tempStepIds.set('/fake test', 'tempStepId');
397+
386398
reporter._finishStep(
387-
{ status: TEST_ITEM_STATUSES.FAILED, failureMessages: ['error message'] },
399+
{
400+
status: TEST_ITEM_STATUSES.FAILED,
401+
failureMessages: ['error message'],
402+
ancestorTitles: [],
403+
title: 'fake test',
404+
},
388405
false,
389406
);
390407

391-
expect(spyFinishFailedTest).toHaveBeenCalledWith('error message');
408+
expect(spyFinishFailedTest).toHaveBeenCalledWith('tempStepId', 'error message');
392409
expect(spyFinishPassedTest).not.toHaveBeenCalled();
393410
expect(spyFinishSkippedTest).not.toHaveBeenCalled();
394411
});
@@ -398,7 +415,14 @@ describe('index script', () => {
398415
const spyFinishFailedTest = jest.spyOn(reporter, '_finishFailedStep');
399416
const spyFinishSkippedTest = jest.spyOn(reporter, '_finishSkippedStep');
400417

401-
reporter._finishStep({ status: TEST_ITEM_STATUSES.SKIPPED, failureMessages: [] });
418+
reporter.tempStepIds.set('/fake test', 'tempStepId');
419+
420+
reporter._finishStep({
421+
status: TEST_ITEM_STATUSES.SKIPPED,
422+
failureMessages: [],
423+
ancestorTitles: [],
424+
title: 'fake test',
425+
});
402426

403427
expect(spyFinishSkippedTest).toHaveBeenCalled();
404428
expect(spyFinishPassedTest).not.toHaveBeenCalled();
@@ -447,7 +471,7 @@ describe('index script', () => {
447471
};
448472
reporter.tempStepId = 'tempStepId';
449473

450-
reporter._finishPassedStep(false);
474+
reporter._finishPassedStep('tempStepId', false);
451475

452476
expect(reporter.client.finishTestItem).toHaveBeenCalledWith(
453477
'tempStepId',
@@ -467,9 +491,13 @@ describe('index script', () => {
467491
};
468492
reporter.tempStepId = tempStepId;
469493

470-
reporter._finishFailedStep(errorMessage, false);
494+
reporter._finishFailedStep('tempStepId', errorMessage, false);
471495

472-
expect(spySendLog).toHaveBeenCalledWith({ message: errorMessage, level: LOG_LEVEL.ERROR });
496+
expect(spySendLog).toHaveBeenCalledWith({
497+
message: errorMessage,
498+
level: LOG_LEVEL.ERROR,
499+
tempStepId: 'tempStepId',
500+
});
473501
expect(reporter.client.finishTestItem).toHaveBeenCalledWith(
474502
tempStepId,
475503
expectedFinishTestItemParameter,
@@ -486,7 +514,7 @@ describe('index script', () => {
486514
reporter.tempStepId = 'tempStepId';
487515
reporter.reportOptions.extendTestDescriptionWithLastError = false;
488516

489-
reporter._finishFailedStep('error message', false);
517+
reporter._finishFailedStep('tempStepId', 'error message', false);
490518

491519
expect(reporter.client.finishTestItem).toHaveBeenCalledWith(
492520
'tempStepId',
@@ -503,7 +531,7 @@ describe('index script', () => {
503531
};
504532
reporter.tempStepId = 'tempStepId';
505533

506-
reporter._finishSkippedStep(false);
534+
reporter._finishSkippedStep('tempStepId', false);
507535

508536
expect(reporter.client.finishTestItem).toHaveBeenCalledWith(
509537
'tempStepId',
@@ -519,7 +547,7 @@ describe('index script', () => {
519547
reporter.tempStepId = 'tempStepId';
520548
reporter.reportOptions.skippedIssue = false;
521549

522-
reporter._finishSkippedStep(false);
550+
reporter._finishSkippedStep('tempStepId', false);
523551

524552
expect(reporter.client.finishTestItem).toHaveBeenCalledWith(
525553
'tempStepId',

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
module.exports = {
1818
moduleFileExtensions: ['js'],
1919
testRegex: '/__tests__/.*\\.spec.(js)$',
20-
collectCoverageFrom: ['./utils/**', './index.js'],
20+
collectCoverageFrom: ['src/**'],
2121
coverageThreshold: {
2222
global: {
2323
branches: 80,

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/reporter.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,46 +201,54 @@ class JestReportPortal {
201201
_finishStep(test) {
202202
const errorMsg = test.failureMessages[0];
203203

204+
const fullName = getFullStepName(test);
205+
const tempStepId = this.tempStepIds.get(fullName);
206+
207+
if (tempStepId === undefined) {
208+
console.error(`Could not finish Test Step - "${fullName}". tempId not found`);
209+
return;
210+
}
211+
204212
switch (test.status) {
205213
case TEST_ITEM_STATUSES.PASSED:
206-
this._finishPassedStep();
214+
this._finishPassedStep(tempStepId);
207215
break;
208216
case TEST_ITEM_STATUSES.FAILED:
209-
this._finishFailedStep(errorMsg);
217+
this._finishFailedStep(tempStepId, errorMsg);
210218
break;
211219
default:
212-
this._finishSkippedStep();
220+
this._finishSkippedStep(tempStepId);
213221
}
214222
}
215223

216-
_finishPassedStep() {
224+
_finishPassedStep(tempStepId) {
217225
const status = TEST_ITEM_STATUSES.PASSED;
218-
const { promise } = this.client.finishTestItem(this.tempStepId, { status });
226+
const { promise } = this.client.finishTestItem(tempStepId, { status });
219227

220228
promiseErrorHandler(promise);
221229
this.promises.push(promise);
222230
}
223231

224-
_finishFailedStep(failureMessage) {
232+
_finishFailedStep(tempStepId, failureMessage) {
225233
const status = TEST_ITEM_STATUSES.FAILED;
226234
const description =
227235
this.reportOptions.extendTestDescriptionWithLastError === false
228236
? null
229237
: `\`\`\`error\n${stripAnsi(failureMessage)}\n\`\`\``;
230238
const finishTestObj = { status, ...(description && { description }) };
231239

232-
this.sendLog({ message: failureMessage, level: LOG_LEVEL.ERROR });
240+
this.sendLog({ message: failureMessage, level: LOG_LEVEL.ERROR, tempStepId });
233241

234-
const { promise } = this.client.finishTestItem(this.tempStepId, finishTestObj);
242+
const { promise } = this.client.finishTestItem(tempStepId, finishTestObj);
235243

236244
promiseErrorHandler(promise);
237245
this.promises.push(promise);
238246
}
239247

240-
sendLog({ level = LOG_LEVEL.INFO, message = '', file, time }) {
248+
sendLog({ level = LOG_LEVEL.INFO, message = '', file, time, tempStepId }) {
241249
const newMessage = stripAnsi(message);
242250
const { promise } = this.client.sendLog(
243-
this.tempStepId,
251+
tempStepId === undefined ? this.tempStepId : tempStepId,
244252
{
245253
message: newMessage,
246254
level,
@@ -253,14 +261,14 @@ class JestReportPortal {
253261
this.promises.push(promise);
254262
}
255263

256-
_finishSkippedStep() {
264+
_finishSkippedStep(tempStepId) {
257265
const status = 'skipped';
258266
const issue = this.reportOptions.skippedIssue === false ? { issueType: 'NOT_ISSUE' } : null;
259267
const finishTestObj = {
260268
status,
261269
...(issue && { issue }),
262270
};
263-
const { promise } = this.client.finishTestItem(this.tempStepId, finishTestObj);
271+
const { promise } = this.client.finishTestItem(tempStepId, finishTestObj);
264272

265273
promiseErrorHandler(promise);
266274
this.promises.push(promise);

version_fragment

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
minor
1+
patch

0 commit comments

Comments
 (0)