Skip to content

Commit

Permalink
Merge pull request #106 from reportportal/develop
Browse files Browse the repository at this point in the history
Release 5.0.4
  • Loading branch information
renkyoji authored May 30, 2022
2 parents c6d82a8 + 43ce73f commit 99dda22
Show file tree
Hide file tree
Showing 15 changed files with 2,259 additions and 4,957 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup NodeJS
uses: actions/setup-node@v2
with:
node-version: '12'
- name: Configure git
run: |
git config --global user.email "reportportal.io"
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ node_modules/
# ide
.idea/

coverage/

.npmrc
4 changes: 0 additions & 4 deletions .npmignore

This file was deleted.

12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
### Added
- Possibility to provide endpoint url via `RP_ENDPOINT` environment variable
- New [option](./README.md#loglaunchlink-flag) `logLaunchLink` to print launch url in console

### Fixed
- The duration of tests and suites is now displayed correctly
- The reporter will now wait for a report on all tests
- Security vulnerabilities
- Tests without describe block causes error [#82](https://github.com/reportportal/agent-js-jest/issues/82)

### Changed
- Package size reduced

## [5.0.3] - 2021-06-23
### Fixed
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ In your jest config section of `package.json`, add the following entry:
"project": "YourReportPortalProjectName",
"launch": "YourLauncherName",
"description": "YourDescription",
"logLaunchLink": true,
"attributes": [
{
"key": "YourKey",
Expand Down Expand Up @@ -60,6 +61,7 @@ module.exports = {
"project": "YourReportPortalProjectName",
"launch": "YourLauncherName",
"description": "YourDescription",
"logLaunchLink": true,
"attributes": [
{
"key": "YourKey",
Expand All @@ -80,8 +82,10 @@ It's possible by using environment variables, it's important to mention that env
```shell
$ export RP_TOKEN=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
$ export RP_PROJECT_NAME=MY_AWESOME_PROJECT
$ export RP_ENDPOINT=MY_RP_ENDPOINT
$ export RP_LAUNCH=MY_COOL_LAUNCHER
$ export RP_ATTRIBUTES=key:value,key:value,value
$ export RP_LAUNCH_ID=EXIST_LAUNCH_ID
```
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.
Expand Down Expand Up @@ -139,6 +143,16 @@ Example:
"debug": true
```
## LogLaunchLink flag:
This flag allows print the URL of the Launch of the tests in console.
Example:
```json
"logLaunchLink": true
```
## REST Client config:
Optional property.<br/>
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.3
5.0.4-SNAPSHOT
4 changes: 2 additions & 2 deletions __tests__/getOptions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const {
options,
getAppOptions,
getEnvOptions,
} = require('./../utils/getOptions');
const constants = require('./../constants/index');
} = require('../utils/getOptions');
const constants = require('../constants/index');

describe('Get Options script', () => {
const OLD_ENV = process.env;
Expand Down
30 changes: 17 additions & 13 deletions __tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
const path = require('path');
const { getOptions, RPClient } = require('./mocks/reportportal-client.mock');
const JestReportPortal = require('../index');
const pjson = require('./../package.json');
const pjson = require('../package.json');

const testItemStatuses = { PASSED: 'passed', FAILED: 'failed', SKIPPED: 'pending' };
const GLOBAL_CONFIG = {};
Expand All @@ -30,6 +30,7 @@ const systemAttr = {
value: `${pjson.name}|${pjson.version}`,
system: true,
};
const duration = 5;
const testResult = {
testResults: [
{
Expand All @@ -38,6 +39,7 @@ const testResult = {
ancestorTitles: ['Suite name', 'Test name'],
failureMessages: 'error message',
invocations: 1,
duration,
},
],
};
Expand Down Expand Up @@ -117,8 +119,10 @@ describe('index script', () => {

reporter.onTestResult(testObj, testResult);

expect(spyStartSuite).toHaveBeenCalledWith(testResult.testResults[0].ancestorTitles[0], testObj.path);
expect(spyStartTest).toHaveBeenCalledWith(testResult.testResults[0], testObj.path);
expect(spyStartSuite).toHaveBeenCalledWith(
testResult.testResults[0].ancestorTitles[0], testObj.path, duration,
);
expect(spyStartTest).toHaveBeenCalledWith(testResult.testResults[0], testObj.path, duration);
expect(spyStartStep).toHaveBeenCalledWith(testResult.testResults[0], false, testObj.path);
expect(spyFinishStep).toHaveBeenCalledWith(testResult.testResults[0], false);
expect(spyFinishTest).toHaveBeenCalledWith('1234', 'tempTestId');
Expand Down Expand Up @@ -203,10 +207,10 @@ describe('index script', () => {
});

describe('onRunComplete', () => {
test('finishLaunch should be called with tempLaunchId', () => {
test('finishLaunch should be called with tempLaunchId', async () => {
reporter.tempLaunchId = 'tempLaunchId';

reporter.onRunComplete();
await reporter.onRunComplete();

expect(reporter.client.finishLaunch).toHaveBeenCalledWith('tempLaunchId');
});
Expand All @@ -220,12 +224,12 @@ describe('index script', () => {
type: 'SUITE',
name: 'suite name',
codeRef: 'example.js/suite name',
startTime: new Date().valueOf(),
startTime: new Date().valueOf() - duration,
};
const expectedTempSuiteIds = new Map([['suite name', 'startTestItem']]);
reporter.tempLaunchId = 'tempLaunchId';

reporter._startSuite('suite name', testObj.path);
reporter._startSuite('suite name', testObj.path, duration);

expect(reporter.client.startTestItem).toHaveBeenCalledWith(expectedStartTestItemParameter, 'tempLaunchId');
expect(reporter.tempSuiteIds).toEqual(expectedTempSuiteIds);
Expand All @@ -248,13 +252,13 @@ describe('index script', () => {
type: 'TEST',
name: 'Test name',
codeRef: 'example.js/Suite name/Test name',
startTime: new Date().valueOf(),
startTime: new Date().valueOf() - duration,
};
const expectedTempTestIds = new Map([['Suite name/Test name', 'startTestItem']]);
reporter.tempLaunchId = 'tempLaunchId';
reporter.tempSuiteIds = new Map([['Suite name', 'suiteId']]);

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

expect(reporter.client.startTestItem)
.toHaveBeenCalledWith(expectedStartTestItemParameter, 'tempLaunchId', 'suiteId');
Expand All @@ -278,12 +282,12 @@ describe('index script', () => {
name: 'Step',
codeRef: 'example.js/Suite/Test/Step',
retry: true,
startTime: new Date().valueOf(),
startTime: new Date().valueOf() - duration,
};
reporter.tempLaunchId = 'tempLaunchId';
reporter.tempTestIds = new Map([['Suite/Test', 'tempTestId']]);

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

expect(reporter.client.startTestItem)
.toHaveBeenCalledWith(expectedStartStepItemParameter, 'tempLaunchId', 'tempTestId');
Expand All @@ -297,12 +301,12 @@ describe('index script', () => {
name: 'Step',
codeRef: 'example.js/Suite/Step',
retry: true,
startTime: new Date().valueOf(),
startTime: new Date().valueOf() - duration,
};
reporter.tempLaunchId = 'tempLaunchId';
reporter.tempSuiteIds = new Map([['Suite', 'tempSuiteId']]);

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

expect(reporter.client.startTestItem)
.toHaveBeenCalledWith(expectedStartStepItemParameter, 'tempLaunchId', 'tempSuiteId');
Expand Down
3 changes: 2 additions & 1 deletion __tests__/mocks/reportportal-client.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const reporterOptions = {
project: 'projectName',
launch: 'launcherName',
description: 'description',
logLaunchLink: true,
attributes: [
{
key: 'YourKey',
Expand Down Expand Up @@ -77,6 +78,6 @@ class RPClient {
}

module.exports = {
getOptions: options => Object.assign(reporterOptions, options),
getOptions: (options) => Object.assign(reporterOptions, options),
RPClient,
};
17 changes: 9 additions & 8 deletions __tests__/objectUtils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const {
getFullTestName,
getFullStepName,
getSystemAttributes,
} = require('./../utils/objectUtils');
const pjson = require('./../package.json');
} = require('../utils/objectUtils');
const pjson = require('../package.json');

const defaultOptions = {
launch: 'launchName',
Expand All @@ -46,6 +46,7 @@ const defaultOptions = {
};
const currentDate = new Date();
const RealDate = Date;
const duration = 5;

describe('Object Utils script', () => {
const OLD_ENV = process.env;
Expand Down Expand Up @@ -124,10 +125,10 @@ describe('Object Utils script', () => {
type: 'STEP',
name: 'step title',
retry: true,
startTime: new Date().valueOf(),
startTime: new Date().valueOf() - duration,
};

const stepStartObject = getStepStartObject('step title', true);
const stepStartObject = getStepStartObject('step title', true, undefined, duration);

expect(stepStartObject).toBeDefined();
expect(stepStartObject).toEqual(expectedStepStartObject);
Expand All @@ -139,10 +140,10 @@ describe('Object Utils script', () => {
const expectedTestStartObject = {
type: 'TEST',
name: 'test title',
startTime: new Date().valueOf(),
startTime: new Date().valueOf() - duration,
};

const testStartObject = getTestStartObject('test title');
const testStartObject = getTestStartObject('test title', undefined, duration);

expect(testStartObject).toBeDefined();
expect(testStartObject).toEqual(expectedTestStartObject);
Expand All @@ -154,10 +155,10 @@ describe('Object Utils script', () => {
const expectedSuiteStartObject = {
type: 'SUITE',
name: 'suite name',
startTime: new Date().valueOf(),
startTime: new Date().valueOf() - duration,
};

const suiteStartObject = getSuiteStartObject('suite name');
const suiteStartObject = getSuiteStartObject('suite name', undefined, duration);

expect(suiteStartObject).toBeDefined();
expect(suiteStartObject).toEqual(expectedSuiteStartObject);
Expand Down
Loading

0 comments on commit 99dda22

Please sign in to comment.