Skip to content

Commit d1473ec

Browse files
authored
Merge pull request #145 from reportportal/develop
Release 5.1.0
2 parents c6d3957 + 5e285fa commit d1473ec

20 files changed

+1798
-1270
lines changed

.github/workflows/CI-pipeline.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@ name: CI-pipeline
33
on:
44
push:
55
branches:
6-
- master
76
- develop
7+
- '!master'
8+
paths-ignore:
9+
- README.md
10+
- CHANGELOG.md
811
pull_request:
912

1013
jobs:
1114
test:
1215
runs-on: ubuntu-latest
1316
steps:
1417
- name: Checkout repository
15-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1619
- name: Set up Node.js
17-
uses: actions/setup-node@v3
20+
uses: actions/setup-node@v4
1821
with:
1922
node-version: 18
2023
- name: Install of node dependencies

.github/workflows/publish.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout repository
12-
uses: actions/checkout@v3
12+
uses: actions/checkout@v4
1313
- name: Set up Node.js
14-
uses: actions/setup-node@v3
14+
uses: actions/setup-node@v4
1515
with:
1616
node-version: 18
1717
- name: Install of node dependencies
@@ -26,9 +26,9 @@ jobs:
2626
runs-on: ubuntu-latest
2727
steps:
2828
- name: Checkout repository
29-
uses: actions/checkout@v3
29+
uses: actions/checkout@v4
3030
- name: Set up Node.js
31-
uses: actions/setup-node@v3
31+
uses: actions/setup-node@v4
3232
with:
3333
node-version: 18
3434
registry-url: 'https://registry.npmjs.org'
@@ -42,7 +42,7 @@ jobs:
4242
env:
4343
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
4444
- name: Set up Node.js
45-
uses: actions/setup-node@v3
45+
uses: actions/setup-node@v4
4646
with:
4747
node-version: 18
4848
registry-url: 'https://npm.pkg.github.com'

.github/workflows/release.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
branches:
66
- master
7+
paths-ignore:
8+
- '.github/**'
9+
- README.md
10+
- CHANGELOG.md
711

812
env:
913
versionFileName: 'VERSION'
@@ -16,7 +20,7 @@ jobs:
1620
releaseVersion: ${{ steps.exposeVersion.outputs.releaseVersion }}
1721
steps:
1822
- name: Checkout repository
19-
uses: actions/checkout@v3
23+
uses: actions/checkout@v4
2024
- name: Read version
2125
id: readVersion
2226
run: |
@@ -61,9 +65,9 @@ jobs:
6165
versionInfo: ${{ steps.readChangelogEntry.outputs.log_entry }}
6266
steps:
6367
- name: Checkout repository
64-
uses: actions/checkout@v3
68+
uses: actions/checkout@v4
6569
- name: Setup NodeJS
66-
uses: actions/setup-node@v3
70+
uses: actions/setup-node@v4
6771
with:
6872
node-version: '12'
6973
- name: Configure git
@@ -113,6 +117,7 @@ jobs:
113117
echo "patch" > ${{ env.versionFragmentFileName }}
114118
git status
115119
git add ${{ env.versionFileName }}
120+
git add ${{ env.versionFragmentFileName }}
116121
git commit -m "${{ needs.calculate-version.outputs.releaseVersion }} -> ${{ steps.bumpSnapshotVersion.outputs.next-version }}-SNAPSHOT"
117122
git push origin develop
118123
@@ -121,7 +126,7 @@ jobs:
121126
runs-on: ubuntu-latest
122127
steps:
123128
- name: Checkout repository
124-
uses: actions/checkout@v3
129+
uses: actions/checkout@v4
125130
- name: Create Release
126131
id: createRelease
127132
uses: actions/create-release@v1

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
### Added
2+
- `ReportingApi` with `attachment` method support. Resolves [#122](https://github.com/reportportal/agent-js-jest/issues/122).
3+
- `extendTestDescriptionWithLastError` config option to extend test description with last error message. Resolves [#136](https://github.com/reportportal/agent-js-jest/issues/136). Thanks to [artsiomBandarenka](https://github.com/artsiomBandarenka).
4+
### Changed
5+
- **Breaking change** Drop support of Node.js 10. The version [5.0.8](https://github.com/reportportal/agent-js-jest/releases/tag/v5.0.8) is the latest that supports it.
6+
- `@reportportal/client-javascript` bumped to version `5.1.4`.
7+
### Security
8+
- Updated versions of vulnerable packages (braces).
9+
### Deprecated
10+
- Node.js 12 usage. This minor version is the latest that supports Node.js 12.
11+
- `token` config option. Use `apiKey` instead.
112

213
## [5.0.8] - 2024-01-19
314
### Deprecated

README.md

Lines changed: 49 additions & 19 deletions
Large diffs are not rendered by default.

VERSION

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

__tests__/getOptions.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
const fs = require('fs');
1919
const path = require('path');
2020
const process = require('process');
21-
const { options, getAppOptions, getEnvOptions } = require('../utils/getOptions');
22-
const constants = require('../constants/index');
21+
const { options, getAppOptions, getEnvOptions } = require('../src/utils/getOptions');
22+
const constants = require('../src/constants');
2323

2424
describe('Get Options script', () => {
2525
const OLD_ENV = process.env;

__tests__/index.spec.js

Lines changed: 63 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,18 @@
1717
/* eslint-disable no-undef */
1818
const path = require('path');
1919
const { getOptions, RPClient } = require('./mocks/reportportal-client.mock');
20-
const JestReportPortal = require('../index');
20+
const JestReportPortal = require('../src');
21+
const { TEST_ITEM_STATUSES, LOG_LEVEL } = require('../src/constants');
2122
const pjson = require('../package.json');
23+
const {
24+
duration,
25+
skippedTestResult,
26+
testResult,
27+
testObj,
28+
mockDate,
29+
mockFile,
30+
} = require('./mocks/data');
2231

23-
const testItemStatuses = { PASSED: 'passed', FAILED: 'failed', SKIPPED: 'pending' };
2432
const GLOBAL_CONFIG = {};
2533
const options = getOptions();
2634
const currentDate = new Date();
@@ -30,22 +38,6 @@ const systemAttr = {
3038
value: `${pjson.name}|${pjson.version}`,
3139
system: true,
3240
};
33-
const duration = 5;
34-
const testResult = {
35-
testResults: [
36-
{
37-
title: 'Title',
38-
status: 'failed',
39-
ancestorTitles: ['Suite name', 'Test name'],
40-
failureMessages: 'error message',
41-
invocations: 1,
42-
duration,
43-
},
44-
],
45-
};
46-
const testObj = {
47-
path: `C:${path.sep}testProject${path.sep}example.js`,
48-
};
4941

5042
describe('index script', () => {
5143
let reporter;
@@ -118,17 +110,13 @@ describe('index script', () => {
118110
reporter.onTestResult(testObj, testResult);
119111

120112
expect(spyStartSuite).toHaveBeenCalledWith(
121-
testResult.testResults[0].ancestorTitles[0],
122-
testObj.path,
123-
duration,
124-
);
125-
expect(spyStartTest).toHaveBeenCalledWith(
126-
testResult.testResults[0],
113+
skippedTestResult.ancestorTitles[0],
127114
testObj.path,
128115
duration,
129116
);
130-
expect(spyStartStep).toHaveBeenCalledWith(testResult.testResults[0], false, testObj.path);
131-
expect(spyFinishStep).toHaveBeenCalledWith(testResult.testResults[0], false);
117+
expect(spyStartTest).toHaveBeenCalledWith(skippedTestResult, testObj.path, duration);
118+
expect(spyStartStep).toHaveBeenCalledWith(skippedTestResult, false, testObj.path);
119+
expect(spyFinishStep).toHaveBeenCalledWith(skippedTestResult);
132120
expect(spyFinishTest).toHaveBeenCalledWith('1234', 'tempTestId');
133121
expect(spyFinishSuite).toHaveBeenCalledWith('4321', 'tempSuiteId');
134122
},
@@ -143,8 +131,8 @@ describe('index script', () => {
143131

144132
reporter.onTestResult(testObj, testResult);
145133

146-
expect(spyStartStep).toHaveBeenCalledWith(testResult.testResults[0], false, testObj.path);
147-
expect(spyFinishStep).toHaveBeenCalledWith(testResult.testResults[0], false);
134+
expect(spyStartStep).toHaveBeenCalledWith(skippedTestResult, false, testObj.path);
135+
expect(spyFinishStep).toHaveBeenCalledWith(skippedTestResult);
148136
expect(spyStartStep).toHaveBeenCalledTimes(1);
149137
expect(spyFinishStep).toHaveBeenCalledTimes(1);
150138
},
@@ -156,13 +144,14 @@ describe('index script', () => {
156144
() => {
157145
const spyStartStep = jest.spyOn(reporter, '_startStep');
158146
const spyFinishStep = jest.spyOn(reporter, '_finishStep');
147+
159148
const testResult = {
160149
testResults: [
161150
{
162151
title: 'Title',
163-
status: 'failed',
152+
status: TEST_ITEM_STATUSES.SKIPPED,
164153
ancestorTitles: ['Suite name', 'Test name'],
165-
failureMessages: 'error message',
154+
failureMessages: [],
166155
invocations: 2,
167156
},
168157
],
@@ -171,7 +160,7 @@ describe('index script', () => {
171160
reporter.onTestResult(testObj, testResult);
172161

173162
expect(spyStartStep).toHaveBeenCalledWith(testResult.testResults[0], true, testObj.path);
174-
expect(spyFinishStep).toHaveBeenCalledWith(testResult.testResults[0], true);
163+
expect(spyFinishStep).toHaveBeenCalledWith(testResult.testResults[0]);
175164
expect(spyStartStep).toHaveBeenCalledTimes(2);
176165
expect(spyFinishStep).toHaveBeenCalledTimes(2);
177166
},
@@ -187,17 +176,17 @@ describe('index script', () => {
187176
testResults: [
188177
{
189178
title: 'Title',
190-
status: 'failed',
179+
status: TEST_ITEM_STATUSES.SKIPPED,
191180
ancestorTitles: ['Suite name', 'Test name'],
192-
failureMessages: 'error message',
181+
failureMessages: [],
193182
},
194183
],
195184
};
196185

197186
reporter.onTestResult(testObj, testResult);
198187

199188
expect(spyStartStep).toHaveBeenCalledWith(testResult.testResults[0], false, testObj.path);
200-
expect(spyFinishStep).toHaveBeenCalledWith(testResult.testResults[0], false);
189+
expect(spyFinishStep).toHaveBeenCalledWith(testResult.testResults[0]);
201190
},
202191
);
203192

@@ -358,19 +347,20 @@ describe('index script', () => {
358347
});
359348
});
360349

361-
describe('_sendLog', () => {
350+
describe('sendLog', () => {
362351
test('sendLog should be called with parameters', () => {
363-
const expectedLogObjectParameter = {
364-
message: 'message',
365-
level: 'error',
366-
};
367352
reporter.tempStepId = 'tempStepId';
368353

369-
reporter._sendLog('message');
354+
reporter.sendLog({ message: 'message', level: LOG_LEVEL.ERROR, file: mockFile });
370355

371356
expect(reporter.client.sendLog).toHaveBeenCalledWith(
372357
'tempStepId',
373-
expectedLogObjectParameter,
358+
{
359+
message: 'message',
360+
level: LOG_LEVEL.ERROR,
361+
time: mockDate,
362+
},
363+
mockFile,
374364
);
375365
});
376366
});
@@ -381,7 +371,7 @@ describe('index script', () => {
381371
const spyFinishFailedTest = jest.spyOn(reporter, '_finishFailedStep');
382372
const spyFinishSkippedTest = jest.spyOn(reporter, '_finishSkippedStep');
383373

384-
reporter._finishStep({ status: testItemStatuses.PASSED, failureMessages: [] });
374+
reporter._finishStep({ status: TEST_ITEM_STATUSES.PASSED, failureMessages: [] });
385375

386376
expect(spyFinishPassedTest).toHaveBeenCalled();
387377
expect(spyFinishFailedTest).not.toHaveBeenCalled();
@@ -394,11 +384,11 @@ describe('index script', () => {
394384
const spyFinishSkippedTest = jest.spyOn(reporter, '_finishSkippedStep');
395385

396386
reporter._finishStep(
397-
{ status: testItemStatuses.FAILED, failureMessages: ['error message'] },
387+
{ status: TEST_ITEM_STATUSES.FAILED, failureMessages: ['error message'] },
398388
false,
399389
);
400390

401-
expect(spyFinishFailedTest).toHaveBeenCalledWith('error message', false);
391+
expect(spyFinishFailedTest).toHaveBeenCalledWith('error message');
402392
expect(spyFinishPassedTest).not.toHaveBeenCalled();
403393
expect(spyFinishSkippedTest).not.toHaveBeenCalled();
404394
});
@@ -408,7 +398,7 @@ describe('index script', () => {
408398
const spyFinishFailedTest = jest.spyOn(reporter, '_finishFailedStep');
409399
const spyFinishSkippedTest = jest.spyOn(reporter, '_finishSkippedStep');
410400

411-
reporter._finishStep({ status: testItemStatuses.SKIPPED, failureMessages: [] });
401+
reporter._finishStep({ status: TEST_ITEM_STATUSES.SKIPPED, failureMessages: [] });
412402

413403
expect(spyFinishSkippedTest).toHaveBeenCalled();
414404
expect(spyFinishPassedTest).not.toHaveBeenCalled();
@@ -454,7 +444,6 @@ describe('index script', () => {
454444
test('finishTestItem should be called with parameters', () => {
455445
const expectedFinishTestItemParameter = {
456446
status: 'passed',
457-
retry: false,
458447
};
459448
reporter.tempStepId = 'tempStepId';
460449

@@ -468,29 +457,49 @@ describe('index script', () => {
468457
});
469458

470459
describe('_finishFailedStep', () => {
471-
test('_sendLog should be called with failure message, finishTestItem should be called with parameters', () => {
472-
const spySendLog = jest.spyOn(reporter, '_sendLog');
460+
test('sendLog should be called with failure message, finishTestItem should be called with parameters', () => {
461+
const spySendLog = jest.spyOn(reporter, 'sendLog');
462+
const errorMessage = 'error message';
463+
const tempStepId = 'tempStepId';
473464
const expectedFinishTestItemParameter = {
474465
status: 'failed',
475-
retry: false,
466+
description: '```error\nerror message\n```',
476467
};
477-
reporter.tempStepId = 'tempStepId';
468+
reporter.tempStepId = tempStepId;
478469

479-
reporter._finishFailedStep('error message', false);
470+
reporter._finishFailedStep(errorMessage, false);
480471

481-
expect(spySendLog).toHaveBeenCalledWith('error message');
472+
expect(spySendLog).toHaveBeenCalledWith({ message: errorMessage, level: LOG_LEVEL.ERROR });
482473
expect(reporter.client.finishTestItem).toHaveBeenCalledWith(
483-
'tempStepId',
474+
tempStepId,
484475
expectedFinishTestItemParameter,
485476
);
486477
});
478+
479+
test(
480+
'finishTestItem should be called without description parameter ' +
481+
'if extendTestDescriptionWithLastError is false',
482+
() => {
483+
const expectedFinishTestItemParameter = {
484+
status: 'failed',
485+
};
486+
reporter.tempStepId = 'tempStepId';
487+
reporter.reportOptions.extendTestDescriptionWithLastError = false;
488+
489+
reporter._finishFailedStep('error message', false);
490+
491+
expect(reporter.client.finishTestItem).toHaveBeenCalledWith(
492+
'tempStepId',
493+
expectedFinishTestItemParameter,
494+
);
495+
},
496+
);
487497
});
488498

489499
describe('_finishSkippedStep', () => {
490500
test('finishTestItem should be called with parameters', () => {
491501
const expectedFinishTestItemParameter = {
492502
status: 'skipped',
493-
retry: false,
494503
};
495504
reporter.tempStepId = 'tempStepId';
496505

@@ -505,7 +514,6 @@ describe('index script', () => {
505514
test('finishTestItem should be called with issue parameter if skippedIssue is false', () => {
506515
const expectedFinishTestItemParameter = {
507516
status: 'skipped',
508-
retry: false,
509517
issue: { issueType: 'NOT_ISSUE' },
510518
};
511519
reporter.tempStepId = 'tempStepId';

0 commit comments

Comments
 (0)