Skip to content

Commit

Permalink
Merge pull request #145 from reportportal/develop
Browse files Browse the repository at this point in the history
Release 5.1.0
  • Loading branch information
AmsterGet authored Jul 11, 2024
2 parents c6d3957 + 5e285fa commit d1473ec
Show file tree
Hide file tree
Showing 20 changed files with 1,798 additions and 1,270 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/CI-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ name: CI-pipeline
on:
push:
branches:
- master
- develop
- '!master'
paths-ignore:
- README.md
- CHANGELOG.md
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install of node dependencies
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install of node dependencies
Expand All @@ -26,9 +26,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
Expand All @@ -42,7 +42,7 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: 'https://npm.pkg.github.com'
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
push:
branches:
- master
paths-ignore:
- '.github/**'
- README.md
- CHANGELOG.md

env:
versionFileName: 'VERSION'
Expand All @@ -16,7 +20,7 @@ jobs:
releaseVersion: ${{ steps.exposeVersion.outputs.releaseVersion }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Read version
id: readVersion
run: |
Expand Down Expand Up @@ -61,9 +65,9 @@ jobs:
versionInfo: ${{ steps.readChangelogEntry.outputs.log_entry }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup NodeJS
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '12'
- name: Configure git
Expand Down Expand Up @@ -113,6 +117,7 @@ jobs:
echo "patch" > ${{ env.versionFragmentFileName }}
git status
git add ${{ env.versionFileName }}
git add ${{ env.versionFragmentFileName }}
git commit -m "${{ needs.calculate-version.outputs.releaseVersion }} -> ${{ steps.bumpSnapshotVersion.outputs.next-version }}-SNAPSHOT"
git push origin develop
Expand All @@ -121,7 +126,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Create Release
id: createRelease
uses: actions/create-release@v1
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
### Added
- `ReportingApi` with `attachment` method support. Resolves [#122](https://github.com/reportportal/agent-js-jest/issues/122).
- `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).
### Changed
- **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.
- `@reportportal/client-javascript` bumped to version `5.1.4`.
### Security
- Updated versions of vulnerable packages (braces).
### Deprecated
- Node.js 12 usage. This minor version is the latest that supports Node.js 12.
- `token` config option. Use `apiKey` instead.

## [5.0.8] - 2024-01-19
### Deprecated
Expand Down
68 changes: 49 additions & 19 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.8
5.0.9-SNAPSHOT
4 changes: 2 additions & 2 deletions __tests__/getOptions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
const fs = require('fs');
const path = require('path');
const process = require('process');
const { options, getAppOptions, getEnvOptions } = require('../utils/getOptions');
const constants = require('../constants/index');
const { options, getAppOptions, getEnvOptions } = require('../src/utils/getOptions');
const constants = require('../src/constants');

describe('Get Options script', () => {
const OLD_ENV = process.env;
Expand Down
118 changes: 63 additions & 55 deletions __tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@
/* eslint-disable no-undef */
const path = require('path');
const { getOptions, RPClient } = require('./mocks/reportportal-client.mock');
const JestReportPortal = require('../index');
const JestReportPortal = require('../src');
const { TEST_ITEM_STATUSES, LOG_LEVEL } = require('../src/constants');
const pjson = require('../package.json');
const {
duration,
skippedTestResult,
testResult,
testObj,
mockDate,
mockFile,
} = require('./mocks/data');

const testItemStatuses = { PASSED: 'passed', FAILED: 'failed', SKIPPED: 'pending' };
const GLOBAL_CONFIG = {};
const options = getOptions();
const currentDate = new Date();
Expand All @@ -30,22 +38,6 @@ const systemAttr = {
value: `${pjson.name}|${pjson.version}`,
system: true,
};
const duration = 5;
const testResult = {
testResults: [
{
title: 'Title',
status: 'failed',
ancestorTitles: ['Suite name', 'Test name'],
failureMessages: 'error message',
invocations: 1,
duration,
},
],
};
const testObj = {
path: `C:${path.sep}testProject${path.sep}example.js`,
};

describe('index script', () => {
let reporter;
Expand Down Expand Up @@ -118,17 +110,13 @@ describe('index script', () => {
reporter.onTestResult(testObj, testResult);

expect(spyStartSuite).toHaveBeenCalledWith(
testResult.testResults[0].ancestorTitles[0],
testObj.path,
duration,
);
expect(spyStartTest).toHaveBeenCalledWith(
testResult.testResults[0],
skippedTestResult.ancestorTitles[0],
testObj.path,
duration,
);
expect(spyStartStep).toHaveBeenCalledWith(testResult.testResults[0], false, testObj.path);
expect(spyFinishStep).toHaveBeenCalledWith(testResult.testResults[0], false);
expect(spyStartTest).toHaveBeenCalledWith(skippedTestResult, testObj.path, duration);
expect(spyStartStep).toHaveBeenCalledWith(skippedTestResult, false, testObj.path);
expect(spyFinishStep).toHaveBeenCalledWith(skippedTestResult);
expect(spyFinishTest).toHaveBeenCalledWith('1234', 'tempTestId');
expect(spyFinishSuite).toHaveBeenCalledWith('4321', 'tempSuiteId');
},
Expand All @@ -143,8 +131,8 @@ describe('index script', () => {

reporter.onTestResult(testObj, testResult);

expect(spyStartStep).toHaveBeenCalledWith(testResult.testResults[0], false, testObj.path);
expect(spyFinishStep).toHaveBeenCalledWith(testResult.testResults[0], false);
expect(spyStartStep).toHaveBeenCalledWith(skippedTestResult, false, testObj.path);
expect(spyFinishStep).toHaveBeenCalledWith(skippedTestResult);
expect(spyStartStep).toHaveBeenCalledTimes(1);
expect(spyFinishStep).toHaveBeenCalledTimes(1);
},
Expand All @@ -156,13 +144,14 @@ describe('index script', () => {
() => {
const spyStartStep = jest.spyOn(reporter, '_startStep');
const spyFinishStep = jest.spyOn(reporter, '_finishStep');

const testResult = {
testResults: [
{
title: 'Title',
status: 'failed',
status: TEST_ITEM_STATUSES.SKIPPED,
ancestorTitles: ['Suite name', 'Test name'],
failureMessages: 'error message',
failureMessages: [],
invocations: 2,
},
],
Expand All @@ -171,7 +160,7 @@ describe('index script', () => {
reporter.onTestResult(testObj, testResult);

expect(spyStartStep).toHaveBeenCalledWith(testResult.testResults[0], true, testObj.path);
expect(spyFinishStep).toHaveBeenCalledWith(testResult.testResults[0], true);
expect(spyFinishStep).toHaveBeenCalledWith(testResult.testResults[0]);
expect(spyStartStep).toHaveBeenCalledTimes(2);
expect(spyFinishStep).toHaveBeenCalledTimes(2);
},
Expand All @@ -187,17 +176,17 @@ describe('index script', () => {
testResults: [
{
title: 'Title',
status: 'failed',
status: TEST_ITEM_STATUSES.SKIPPED,
ancestorTitles: ['Suite name', 'Test name'],
failureMessages: 'error message',
failureMessages: [],
},
],
};

reporter.onTestResult(testObj, testResult);

expect(spyStartStep).toHaveBeenCalledWith(testResult.testResults[0], false, testObj.path);
expect(spyFinishStep).toHaveBeenCalledWith(testResult.testResults[0], false);
expect(spyFinishStep).toHaveBeenCalledWith(testResult.testResults[0]);
},
);

Expand Down Expand Up @@ -358,19 +347,20 @@ describe('index script', () => {
});
});

describe('_sendLog', () => {
describe('sendLog', () => {
test('sendLog should be called with parameters', () => {
const expectedLogObjectParameter = {
message: 'message',
level: 'error',
};
reporter.tempStepId = 'tempStepId';

reporter._sendLog('message');
reporter.sendLog({ message: 'message', level: LOG_LEVEL.ERROR, file: mockFile });

expect(reporter.client.sendLog).toHaveBeenCalledWith(
'tempStepId',
expectedLogObjectParameter,
{
message: 'message',
level: LOG_LEVEL.ERROR,
time: mockDate,
},
mockFile,
);
});
});
Expand All @@ -381,7 +371,7 @@ describe('index script', () => {
const spyFinishFailedTest = jest.spyOn(reporter, '_finishFailedStep');
const spyFinishSkippedTest = jest.spyOn(reporter, '_finishSkippedStep');

reporter._finishStep({ status: testItemStatuses.PASSED, failureMessages: [] });
reporter._finishStep({ status: TEST_ITEM_STATUSES.PASSED, failureMessages: [] });

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

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

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

reporter._finishStep({ status: testItemStatuses.SKIPPED, failureMessages: [] });
reporter._finishStep({ status: TEST_ITEM_STATUSES.SKIPPED, failureMessages: [] });

expect(spyFinishSkippedTest).toHaveBeenCalled();
expect(spyFinishPassedTest).not.toHaveBeenCalled();
Expand Down Expand Up @@ -454,7 +444,6 @@ describe('index script', () => {
test('finishTestItem should be called with parameters', () => {
const expectedFinishTestItemParameter = {
status: 'passed',
retry: false,
};
reporter.tempStepId = 'tempStepId';

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

describe('_finishFailedStep', () => {
test('_sendLog should be called with failure message, finishTestItem should be called with parameters', () => {
const spySendLog = jest.spyOn(reporter, '_sendLog');
test('sendLog should be called with failure message, finishTestItem should be called with parameters', () => {
const spySendLog = jest.spyOn(reporter, 'sendLog');
const errorMessage = 'error message';
const tempStepId = 'tempStepId';
const expectedFinishTestItemParameter = {
status: 'failed',
retry: false,
description: '```error\nerror message\n```',
};
reporter.tempStepId = 'tempStepId';
reporter.tempStepId = tempStepId;

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

expect(spySendLog).toHaveBeenCalledWith('error message');
expect(spySendLog).toHaveBeenCalledWith({ message: errorMessage, level: LOG_LEVEL.ERROR });
expect(reporter.client.finishTestItem).toHaveBeenCalledWith(
'tempStepId',
tempStepId,
expectedFinishTestItemParameter,
);
});

test(
'finishTestItem should be called without description parameter ' +
'if extendTestDescriptionWithLastError is false',
() => {
const expectedFinishTestItemParameter = {
status: 'failed',
};
reporter.tempStepId = 'tempStepId';
reporter.reportOptions.extendTestDescriptionWithLastError = false;

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

expect(reporter.client.finishTestItem).toHaveBeenCalledWith(
'tempStepId',
expectedFinishTestItemParameter,
);
},
);
});

describe('_finishSkippedStep', () => {
test('finishTestItem should be called with parameters', () => {
const expectedFinishTestItemParameter = {
status: 'skipped',
retry: false,
};
reporter.tempStepId = 'tempStepId';

Expand All @@ -505,7 +514,6 @@ describe('index script', () => {
test('finishTestItem should be called with issue parameter if skippedIssue is false', () => {
const expectedFinishTestItemParameter = {
status: 'skipped',
retry: false,
issue: { issueType: 'NOT_ISSUE' },
};
reporter.tempStepId = 'tempStepId';
Expand Down
Loading

0 comments on commit d1473ec

Please sign in to comment.