From 679c72c5ca700fc4e46972d5e89c222b563d0848 Mon Sep 17 00:00:00 2001 From: Steve Zhang Date: Mon, 17 Jun 2024 06:23:44 -0400 Subject: [PATCH] allow using custom client config in checkConnection() method (#206) --- lib/report-portal-client.js | 2 +- package-lock.json | 2 +- spec/report-portal-client.spec.js | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/report-portal-client.js b/lib/report-portal-client.js index 05402e1..30e624d 100644 --- a/lib/report-portal-client.js +++ b/lib/report-portal-client.js @@ -130,7 +130,7 @@ class RPClient { checkConnect() { const url = [this.config.endpoint.replace('/v2', '/v1'), 'user'].join('/'); - return RestClient.request('GET', url, {}, { headers: this.headers }); + return RestClient.request('GET', url, {}, { headers: this.headers, ...this.restClient.getRestConfig()}); } async triggerStatisticsEvent() { diff --git a/package-lock.json b/package-lock.json index 867f5ca..2aba610 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@reportportal/client-javascript", - "version": "5.1.2", + "version": "5.1.4", "license": "Apache-2.0", "dependencies": { "axios": "^1.6.8", diff --git a/spec/report-portal-client.spec.js b/spec/report-portal-client.spec.js index cc3ef88..a8b1f2b 100644 --- a/spec/report-portal-client.spec.js +++ b/spec/report-portal-client.spec.js @@ -136,6 +136,30 @@ describe('ReportPortal javascript client', () => { return expectAsync(request).toBeResolved(); }); + + it('client should include restClientConfig', () => { + const client = new RPClient({ + apiKey: 'test', + project: 'test', + endpoint: 'https://abc.com/v1', + restClientConfig: { + proxy: false, + timeout: 0, + } + }); + spyOn(RestClient, 'request'); + + client.checkConnect(); + + expect(RestClient.request).toHaveBeenCalledWith('GET','https://abc.com/v1/user', {}, { + headers: { + 'User-Agent': 'NodeJS', + Authorization: `bearer test`, + }, + proxy: false, + timeout: 0, + }); + }); }); describe('triggerAnalyticsEvent', () => {