Skip to content

Commit 99dda22

Browse files
authored
Merge pull request #106 from reportportal/develop
Release 5.0.4
2 parents c6d82a8 + 43ce73f commit 99dda22

15 files changed

+2259
-4957
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ jobs:
6262
steps:
6363
- name: Checkout repository
6464
uses: actions/checkout@v2
65+
- name: Setup NodeJS
66+
uses: actions/setup-node@v2
67+
with:
68+
node-version: '12'
6569
- name: Configure git
6670
run: |
6771
git config --global user.email "reportportal.io"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ node_modules/
44
# ide
55
.idea/
66

7+
coverage/
8+
79
.npmrc

.npmignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
### Added
2+
- Possibility to provide endpoint url via `RP_ENDPOINT` environment variable
3+
- New [option](./README.md#loglaunchlink-flag) `logLaunchLink` to print launch url in console
4+
5+
### Fixed
6+
- The duration of tests and suites is now displayed correctly
7+
- The reporter will now wait for a report on all tests
8+
- Security vulnerabilities
9+
- Tests without describe block causes error [#82](https://github.com/reportportal/agent-js-jest/issues/82)
10+
11+
### Changed
12+
- Package size reduced
113

214
## [5.0.3] - 2021-06-23
315
### Fixed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ In your jest config section of `package.json`, add the following entry:
2525
"project": "YourReportPortalProjectName",
2626
"launch": "YourLauncherName",
2727
"description": "YourDescription",
28+
"logLaunchLink": true,
2829
"attributes": [
2930
{
3031
"key": "YourKey",
@@ -60,6 +61,7 @@ module.exports = {
6061
"project": "YourReportPortalProjectName",
6162
"launch": "YourLauncherName",
6263
"description": "YourDescription",
64+
"logLaunchLink": true,
6365
"attributes": [
6466
{
6567
"key": "YourKey",
@@ -80,8 +82,10 @@ It's possible by using environment variables, it's important to mention that env
8082
```shell
8183
$ export RP_TOKEN=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
8284
$ export RP_PROJECT_NAME=MY_AWESOME_PROJECT
85+
$ export RP_ENDPOINT=MY_RP_ENDPOINT
8386
$ export RP_LAUNCH=MY_COOL_LAUNCHER
8487
$ export RP_ATTRIBUTES=key:value,key:value,value
88+
$ export RP_LAUNCH_ID=EXIST_LAUNCH_ID
8589
```
8690
8791
This for your convenience in case you has a continuous job that run your tests and may post the results pointing to a different Report Portal definition of project, launcher name or tags.
@@ -139,6 +143,16 @@ Example:
139143
"debug": true
140144
```
141145
146+
## LogLaunchLink flag:
147+
148+
This flag allows print the URL of the Launch of the tests in console.
149+
150+
Example:
151+
152+
```json
153+
"logLaunchLink": true
154+
```
155+
142156
## REST Client config:
143157
144158
Optional property.<br/>

VERSION

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

__tests__/getOptions.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const {
2222
options,
2323
getAppOptions,
2424
getEnvOptions,
25-
} = require('./../utils/getOptions');
26-
const constants = require('./../constants/index');
25+
} = require('../utils/getOptions');
26+
const constants = require('../constants/index');
2727

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

__tests__/index.spec.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
const path = require('path');
1919
const { getOptions, RPClient } = require('./mocks/reportportal-client.mock');
2020
const JestReportPortal = require('../index');
21-
const pjson = require('./../package.json');
21+
const pjson = require('../package.json');
2222

2323
const testItemStatuses = { PASSED: 'passed', FAILED: 'failed', SKIPPED: 'pending' };
2424
const GLOBAL_CONFIG = {};
@@ -30,6 +30,7 @@ const systemAttr = {
3030
value: `${pjson.name}|${pjson.version}`,
3131
system: true,
3232
};
33+
const duration = 5;
3334
const testResult = {
3435
testResults: [
3536
{
@@ -38,6 +39,7 @@ const testResult = {
3839
ancestorTitles: ['Suite name', 'Test name'],
3940
failureMessages: 'error message',
4041
invocations: 1,
42+
duration,
4143
},
4244
],
4345
};
@@ -117,8 +119,10 @@ describe('index script', () => {
117119

118120
reporter.onTestResult(testObj, testResult);
119121

120-
expect(spyStartSuite).toHaveBeenCalledWith(testResult.testResults[0].ancestorTitles[0], testObj.path);
121-
expect(spyStartTest).toHaveBeenCalledWith(testResult.testResults[0], testObj.path);
122+
expect(spyStartSuite).toHaveBeenCalledWith(
123+
testResult.testResults[0].ancestorTitles[0], testObj.path, duration,
124+
);
125+
expect(spyStartTest).toHaveBeenCalledWith(testResult.testResults[0], testObj.path, duration);
122126
expect(spyStartStep).toHaveBeenCalledWith(testResult.testResults[0], false, testObj.path);
123127
expect(spyFinishStep).toHaveBeenCalledWith(testResult.testResults[0], false);
124128
expect(spyFinishTest).toHaveBeenCalledWith('1234', 'tempTestId');
@@ -203,10 +207,10 @@ describe('index script', () => {
203207
});
204208

205209
describe('onRunComplete', () => {
206-
test('finishLaunch should be called with tempLaunchId', () => {
210+
test('finishLaunch should be called with tempLaunchId', async () => {
207211
reporter.tempLaunchId = 'tempLaunchId';
208212

209-
reporter.onRunComplete();
213+
await reporter.onRunComplete();
210214

211215
expect(reporter.client.finishLaunch).toHaveBeenCalledWith('tempLaunchId');
212216
});
@@ -220,12 +224,12 @@ describe('index script', () => {
220224
type: 'SUITE',
221225
name: 'suite name',
222226
codeRef: 'example.js/suite name',
223-
startTime: new Date().valueOf(),
227+
startTime: new Date().valueOf() - duration,
224228
};
225229
const expectedTempSuiteIds = new Map([['suite name', 'startTestItem']]);
226230
reporter.tempLaunchId = 'tempLaunchId';
227231

228-
reporter._startSuite('suite name', testObj.path);
232+
reporter._startSuite('suite name', testObj.path, duration);
229233

230234
expect(reporter.client.startTestItem).toHaveBeenCalledWith(expectedStartTestItemParameter, 'tempLaunchId');
231235
expect(reporter.tempSuiteIds).toEqual(expectedTempSuiteIds);
@@ -248,13 +252,13 @@ describe('index script', () => {
248252
type: 'TEST',
249253
name: 'Test name',
250254
codeRef: 'example.js/Suite name/Test name',
251-
startTime: new Date().valueOf(),
255+
startTime: new Date().valueOf() - duration,
252256
};
253257
const expectedTempTestIds = new Map([['Suite name/Test name', 'startTestItem']]);
254258
reporter.tempLaunchId = 'tempLaunchId';
255259
reporter.tempSuiteIds = new Map([['Suite name', 'suiteId']]);
256260

257-
reporter._startTest({ ancestorTitles: ['Suite name', 'Test name'] }, testObj.path);
261+
reporter._startTest({ ancestorTitles: ['Suite name', 'Test name'] }, testObj.path, duration);
258262

259263
expect(reporter.client.startTestItem)
260264
.toHaveBeenCalledWith(expectedStartTestItemParameter, 'tempLaunchId', 'suiteId');
@@ -278,12 +282,12 @@ describe('index script', () => {
278282
name: 'Step',
279283
codeRef: 'example.js/Suite/Test/Step',
280284
retry: true,
281-
startTime: new Date().valueOf(),
285+
startTime: new Date().valueOf() - duration,
282286
};
283287
reporter.tempLaunchId = 'tempLaunchId';
284288
reporter.tempTestIds = new Map([['Suite/Test', 'tempTestId']]);
285289

286-
reporter._startStep({ title: 'Step', ancestorTitles: ['Suite', 'Test'] }, true, testObj.path);
290+
reporter._startStep({ title: 'Step', ancestorTitles: ['Suite', 'Test'], duration }, true, testObj.path);
287291

288292
expect(reporter.client.startTestItem)
289293
.toHaveBeenCalledWith(expectedStartStepItemParameter, 'tempLaunchId', 'tempTestId');
@@ -297,12 +301,12 @@ describe('index script', () => {
297301
name: 'Step',
298302
codeRef: 'example.js/Suite/Step',
299303
retry: true,
300-
startTime: new Date().valueOf(),
304+
startTime: new Date().valueOf() - duration,
301305
};
302306
reporter.tempLaunchId = 'tempLaunchId';
303307
reporter.tempSuiteIds = new Map([['Suite', 'tempSuiteId']]);
304308

305-
reporter._startStep({ title: 'Step', ancestorTitles: ['Suite'] }, true, testObj.path);
309+
reporter._startStep({ title: 'Step', ancestorTitles: ['Suite'], duration }, true, testObj.path);
306310

307311
expect(reporter.client.startTestItem)
308312
.toHaveBeenCalledWith(expectedStartStepItemParameter, 'tempLaunchId', 'tempSuiteId');

__tests__/mocks/reportportal-client.mock.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const reporterOptions = {
2020
project: 'projectName',
2121
launch: 'launcherName',
2222
description: 'description',
23+
logLaunchLink: true,
2324
attributes: [
2425
{
2526
key: 'YourKey',
@@ -77,6 +78,6 @@ class RPClient {
7778
}
7879

7980
module.exports = {
80-
getOptions: options => Object.assign(reporterOptions, options),
81+
getOptions: (options) => Object.assign(reporterOptions, options),
8182
RPClient,
8283
};

__tests__/objectUtils.spec.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const {
2727
getFullTestName,
2828
getFullStepName,
2929
getSystemAttributes,
30-
} = require('./../utils/objectUtils');
31-
const pjson = require('./../package.json');
30+
} = require('../utils/objectUtils');
31+
const pjson = require('../package.json');
3232

3333
const defaultOptions = {
3434
launch: 'launchName',
@@ -46,6 +46,7 @@ const defaultOptions = {
4646
};
4747
const currentDate = new Date();
4848
const RealDate = Date;
49+
const duration = 5;
4950

5051
describe('Object Utils script', () => {
5152
const OLD_ENV = process.env;
@@ -124,10 +125,10 @@ describe('Object Utils script', () => {
124125
type: 'STEP',
125126
name: 'step title',
126127
retry: true,
127-
startTime: new Date().valueOf(),
128+
startTime: new Date().valueOf() - duration,
128129
};
129130

130-
const stepStartObject = getStepStartObject('step title', true);
131+
const stepStartObject = getStepStartObject('step title', true, undefined, duration);
131132

132133
expect(stepStartObject).toBeDefined();
133134
expect(stepStartObject).toEqual(expectedStepStartObject);
@@ -139,10 +140,10 @@ describe('Object Utils script', () => {
139140
const expectedTestStartObject = {
140141
type: 'TEST',
141142
name: 'test title',
142-
startTime: new Date().valueOf(),
143+
startTime: new Date().valueOf() - duration,
143144
};
144145

145-
const testStartObject = getTestStartObject('test title');
146+
const testStartObject = getTestStartObject('test title', undefined, duration);
146147

147148
expect(testStartObject).toBeDefined();
148149
expect(testStartObject).toEqual(expectedTestStartObject);
@@ -154,10 +155,10 @@ describe('Object Utils script', () => {
154155
const expectedSuiteStartObject = {
155156
type: 'SUITE',
156157
name: 'suite name',
157-
startTime: new Date().valueOf(),
158+
startTime: new Date().valueOf() - duration,
158159
};
159160

160-
const suiteStartObject = getSuiteStartObject('suite name');
161+
const suiteStartObject = getSuiteStartObject('suite name', undefined, duration);
161162

162163
expect(suiteStartObject).toBeDefined();
163164
expect(suiteStartObject).toEqual(expectedSuiteStartObject);

0 commit comments

Comments
 (0)