Skip to content
Merged
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
85 changes: 85 additions & 0 deletions __tests__/report-portal-client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

client.logDebug('message');

expect(console.log).toHaveBeenCalledWith('message', '');

Check warning on line 37 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected console statement

Check warning on line 37 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement

Check warning on line 37 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 37 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement
});

it('should call console.log with messages if debug is true and dataMsg provided', () => {
Expand All @@ -48,7 +48,7 @@

client.logDebug('message', { key: 1, value: 2 });

expect(console.log).toHaveBeenCalledWith('message', { key: 1, value: 2 });

Check warning on line 51 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected console statement

Check warning on line 51 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement

Check warning on line 51 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 51 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement
});

it('should not call console.log if debug is false', () => {
Expand All @@ -62,7 +62,7 @@

client.logDebug('message');

expect(console.log).not.toHaveBeenCalled();

Check warning on line 65 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected console statement

Check warning on line 65 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement

Check warning on line 65 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 65 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement
});
});

Expand Down Expand Up @@ -876,6 +876,91 @@
});
});

it('should automatically add NOT_ISSUE when status is SKIPPED and skippedIssue is false', function (done) {
const mockClient = new RPClient({

Check failure on line 880 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Insert `⏎······`

Check failure on line 880 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Insert `⏎······`

Check failure on line 880 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Insert `⏎······`

Check failure on line 880 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Insert `⏎······`
apiKey: 'test',

Check failure on line 881 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Insert `··`

Check failure on line 881 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Insert `··`

Check failure on line 881 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Insert `··`

Check failure on line 881 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Insert `··`
endpoint: 'https://reportportal-stub-url',

Check failure on line 882 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Insert `··`

Check failure on line 882 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Insert `··`

Check failure on line 882 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Insert `··`

Check failure on line 882 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Insert `··`
launch: 'test launch',

Check failure on line 883 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Replace `······` with `········`

Check failure on line 883 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Replace `······` with `········`

Check failure on line 883 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Replace `······` with `········`

Check failure on line 883 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Replace `······` with `········`
project: 'test project',

Check failure on line 884 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Insert `··`

Check failure on line 884 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Insert `··`

Check failure on line 884 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Insert `··`

Check failure on line 884 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Insert `··`
skippedIssue: false,

Check failure on line 885 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Insert `··`

Check failure on line 885 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Insert `··`

Check failure on line 885 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Insert `··`

Check failure on line 885 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Insert `··`
}, { name: 'test', version: '1.0.0' });

Check failure on line 886 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Replace `····},·{·name:·'test',·version:·'1.0.0'·}` with `······},⏎······{·name:·'test',·version:·'1.0.0'·},⏎····`

Check failure on line 886 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Replace `····},·{·name:·'test',·version:·'1.0.0'·}` with `······},⏎······{·name:·'test',·version:·'1.0.0'·},⏎····`

Check failure on line 886 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Replace `····},·{·name:·'test',·version:·'1.0.0'·}` with `······},⏎······{·name:·'test',·version:·'1.0.0'·},⏎····`

Check failure on line 886 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Replace `····},·{·name:·'test',·version:·'1.0.0'·}` with `······},⏎······{·name:·'test',·version:·'1.0.0'·},⏎····`

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

Check failure on line 888 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected empty arrow function

Check failure on line 888 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Replace `.spyOn(mockClient,·'finishTestItemPromiseStart')` with `⏎······.spyOn(mockClient,·'finishTestItemPromiseStart')⏎······`

Check failure on line 888 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected empty arrow function

Check failure on line 888 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Replace `.spyOn(mockClient,·'finishTestItemPromiseStart')` with `⏎······.spyOn(mockClient,·'finishTestItemPromiseStart')⏎······`

Check failure on line 888 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected empty arrow function

Check failure on line 888 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Replace `.spyOn(mockClient,·'finishTestItemPromiseStart')` with `⏎······.spyOn(mockClient,·'finishTestItemPromiseStart')⏎······`

Check failure on line 888 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected empty arrow function

Check failure on line 888 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Replace `.spyOn(mockClient,·'finishTestItemPromiseStart')` with `⏎······.spyOn(mockClient,·'finishTestItemPromiseStart')⏎······`

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

Check failure on line 895 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected empty arrow function 'resolveFinish'

Check failure on line 895 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected empty arrow function 'resolveFinish'

Check failure on line 895 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected empty arrow function 'resolveFinish'

Check failure on line 895 in __tests__/report-portal-client.spec.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected empty arrow function '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', () => {
it('should return object with tempId and promise', () => {
const client = new RPClient({ apiKey: 'any', endpoint: 'https://rp.api', project: 'prj' });
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ declare module '@reportportal/client-javascript' {
launchUuidPrintOutput?: string;
restClientConfig?: RestClientConfig;
token?: string;
skippedIssue?: boolean;
/**
* OAuth 2.0 configuration object. When provided, OAuth authentication will be used instead of API key.
*/
Expand Down
1 change: 1 addition & 0 deletions lib/commons/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
if (!calculatedApiKey) {
throw new ReportPortalRequiredOptionError('apiKey');
} else {
console.warn(`Option 'token' is deprecated. Use 'apiKey' instead.`);

Check warning on line 27 in lib/commons/config.js

View workflow job for this annotation

GitHub Actions / test (22)

Unexpected console statement

Check warning on line 27 in lib/commons/config.js

View workflow job for this annotation

GitHub Actions / test (20)

Unexpected console statement

Check warning on line 27 in lib/commons/config.js

View workflow job for this annotation

GitHub Actions / test (18)

Unexpected console statement

Check warning on line 27 in lib/commons/config.js

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement
}
}

Expand Down Expand Up @@ -115,6 +115,7 @@
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.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,10 @@ class RPClient {
...(itemObj.children.length ? {} : { status: RP_STATUSES.PASSED }),
...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}`);
Expand Down
Loading