Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions __tests__/config.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { getClientConfig, getRequiredOption, getApiKey } = require('../lib/commons/config');
const { getClientConfig, getRequiredOption, getApiKey } = require('../build/lib/commons/config');

Check failure on line 1 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Require statement not part of import statement

Check failure on line 1 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Require statement not part of import statement

Check failure on line 1 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Require statement not part of import statement

Check failure on line 1 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Require statement not part of import statement
const {
ReportPortalRequiredOptionError,
ReportPortalValidationError,
} = require('../lib/commons/errors');
} = require('../build/lib/commons/errors');

Check failure on line 5 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Require statement not part of import statement

Check failure on line 5 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Require statement not part of import statement

Check failure on line 5 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Require statement not part of import statement

Check failure on line 5 in __tests__/config.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Require statement not part of import statement

describe('Config commons test suite', () => {
describe('getRequiredOption', () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/helpers.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const os = require('os');

Check failure on line 1 in __tests__/helpers.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Require statement not part of import statement

Check failure on line 1 in __tests__/helpers.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Require statement not part of import statement

Check failure on line 1 in __tests__/helpers.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Require statement not part of import statement

Check failure on line 1 in __tests__/helpers.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Require statement not part of import statement
const fs = require('fs');

Check failure on line 2 in __tests__/helpers.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Require statement not part of import statement

Check failure on line 2 in __tests__/helpers.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Require statement not part of import statement

Check failure on line 2 in __tests__/helpers.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Require statement not part of import statement

Check failure on line 2 in __tests__/helpers.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Require statement not part of import statement
const glob = require('glob');
const helpers = require('../lib/helpers');
const helpers = require('../build/lib/helpers');
const pjson = require('../package.json');

describe('Helpers', () => {
Expand Down
4 changes: 2 additions & 2 deletions __tests__/publicReportingAPI.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const PublicReportingAPI = require('../lib/publicReportingAPI');
const { EVENTS } = require('../lib/constants/events');
const PublicReportingAPI = require('../build/lib/publicReportingAPI').default;
const { EVENTS } = require('../build/lib/constants/events');

describe('PublicReportingAPI', () => {
it('setDescription should trigger process.emit with correct parameters', () => {
Expand Down
90 changes: 87 additions & 3 deletions __tests__/report-portal-client.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const process = require('process');
const RPClient = require('../lib/report-portal-client');
const helpers = require('../lib/helpers');
const { OUTPUT_TYPES } = require('../lib/constants/outputs');
const RPClient = require('../build/lib/report-portal-client').default;
const helpers = require('../build/lib/helpers');
const { OUTPUT_TYPES } = require('../build/lib/constants/outputs');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose the tests should test the sources, not built version.
So, please revert the imports.
Also test files should be also migrated to TypeScript.


describe('ReportPortal javascript client', () => {
afterEach(() => {
Expand Down Expand Up @@ -874,6 +874,90 @@ describe('ReportPortal javascript client', () => {
done();
}, 100);
});

it('should automatically add NOT_ISSUE when status is SKIPPED and skippedIssue is false', function (done) {
const mockClient = new RPClient({
apiKey: 'test',
endpoint: 'https://reportportal-stub-url',
launch: 'test launch',
project: 'test project',
skippedIssue: false,
}, { name: 'test', version: '1.0.0' });

const spyFinishTestItemPromiseStart = jest.spyOn(mockClient, 'finishTestItemPromiseStart').mockImplementation(() => {});

mockClient.map = {
testItemId: {
children: [],
finishSend: false,
promiseFinish: Promise.resolve(),
resolveFinish: () => {},
},
};

const finishTestItemRQ = {
status: 'skipped',
};

mockClient.finishTestItem('testItemId', finishTestItemRQ);

setTimeout(() => {
expect(spyFinishTestItemPromiseStart).toHaveBeenCalledWith(
expect.any(Object),
'testItemId',
expect.objectContaining({
status: 'skipped',
issue: { issueType: 'NOT_ISSUE' },
})
);
done();
}, 50);
});

it('should not add NOT_ISSUE when status is SKIPPED and skippedIssue is true', function (done) {
const mockClient = new RPClient({
apiKey: 'test',
endpoint: 'https://reportportal-stub-url',
launch: 'test launch',
project: 'test project',
skippedIssue: true,
}, { name: 'test', version: '1.0.0' });

const spyFinishTestItemPromiseStart = jest.spyOn(mockClient, 'finishTestItemPromiseStart').mockImplementation(() => {});

mockClient.map = {
testItemId: {
children: [],
finishSend: false,
promiseFinish: Promise.resolve(),
resolveFinish: () => {},
},
};

const finishTestItemRQ = {
status: 'skipped',
};

mockClient.finishTestItem('testItemId', finishTestItemRQ);

setTimeout(() => {
expect(spyFinishTestItemPromiseStart).toHaveBeenCalledWith(
expect.any(Object),
'testItemId',
expect.objectContaining({
status: 'skipped',
})
);
expect(spyFinishTestItemPromiseStart).not.toHaveBeenCalledWith(
expect.any(Object),
'testItemId',
expect.objectContaining({
issue: expect.anything(),
})
);
done();
}, 100);
});
});

describe('saveLog', () => {
Expand Down
4 changes: 2 additions & 2 deletions __tests__/rest.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const nock = require('nock');
const isEqual = require('lodash/isEqual');
const http = require('http');
const RestClient = require('../lib/rest');
const logger = require('../lib/logger');
const RestClient = require('../build/lib/rest').default;
const logger = require('../build/lib/logger');

describe('RestClient', () => {
const options = {
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ declare module '@reportportal/client-javascript' {
launchUuidPrintOutput?: string;
restClientConfig?: Record<string, unknown>;
token?: string;
skippedIssue?: boolean;
}

/**
Expand Down
1 change: 1 addition & 0 deletions lib/commons/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function getClientConfig(options: Partial<ClientConfig>): ClientConfig {
description: options.description,
launchUuidPrint: options.launchUuidPrint,
launchUuidPrintOutput,
skippedIssue: options.skippedIssue,
};
} catch (error) {
// don't throw the error up to not break the entire process
Expand Down
4 changes: 4 additions & 0 deletions lib/report-portal-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,10 @@ class RPClient {
...finishTestItemRQ,
};

if (finishTestItemData.status === RP_STATUSES.SKIPPED && this.config.skippedIssue === false) {
finishTestItemData.issue = { issueType: 'NOT_ISSUE' };
}

itemObj.finishSend = true;
this.logDebug(`Finish all children for test item with tempId ${itemTempId}`);
Promise.allSettled(
Expand Down
1 change: 1 addition & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface ClientConfig {
attributes?: Attribute[];
mode?: string;
description?: string;
skippedIssue?: boolean;
}

export type AgentParams = {
Expand Down
42 changes: 42 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,59 @@
"main": "build/lib/report-portal-client",
"types": "build/lib/report-portal-client.d.ts",
"exports": {
".": {
"node": "./build/lib/report-portal-client.js",
"default": "./build/lib/report-portal-client.js",
"require": "./build/lib/report-portal-client.js",
"import": "./build/lib/report-portal-client.js"
},
"./helpers":{
"node": "./build/lib/helpers.js",
"default": "./build/lib/helpers.js",
"require": "./build/lib/helpers.js",
"import": "./build/lib/helpers.js"
},
"./lib/helpers": {
"node": "./build/lib/helpers.js",
"default": "./build/lib/helpers.js",
"require": "./build/lib/helpers.js",
"import": "./build/lib/helpers.js"
},
"./lib/constants/events": {
"node": "./build/lib/constants/events.js",
"default": "./build/lib/constants/events.js",
"require": "./build/lib/constants/events.js",
"import": "./build/lib/constants/events.js"
},
"./lib/constants/statuses": {
"node": "./build/lib/constants/statuses.js",
"default": "./build/lib/constants/statuses.js",
"require": "./build/lib/constants/statuses.js",
"import": "./build/lib/constants/statuses.js"
},
"./lib/publicReportingAPI": {
"node": "./build/lib/publicReportingAPI.js",
"default": "./build/lib/publicReportingAPI.js",
"require": "./build/lib/publicReportingAPI.js",
"import": "./build/lib/publicReportingAPI.js"
}
},
"typesVersions": {
"*": {
"helpers": [
"./build/lib/helpers.d.ts"
],
"lib/helpers": [
"./build/lib/helpers.d.ts"
],
"lib/constants/events": [
"./build/lib/constants/events.d.ts"
],
"lib/constants/statuses": [
"./build/lib/constants/statuses.d.ts"
],
"lib/publicReportingAPI": [
"./build/lib/publicReportingAPI.d.ts"
]
}
},
Expand Down
Loading