diff --git a/packages/fetch-http-handler/src/fetch-http-handler.browser.spec.ts b/packages/fetch-http-handler/src/fetch-http-handler.browser.spec.ts index 82665fcb775..b5155d531be 100644 --- a/packages/fetch-http-handler/src/fetch-http-handler.browser.spec.ts +++ b/packages/fetch-http-handler/src/fetch-http-handler.browser.spec.ts @@ -92,9 +92,11 @@ describe(FetchHttpHandler.name, () => { const username = "foo"; const password = "bar"; const mockHttpRequest = getMockHttpRequest({ username, password }); - await fetchHttpHandler.handle(mockHttpRequest).catch(error => { - expect(String(error)).toContain("TypeError: Request cannot be constructed from a URL that includes credentials"); - }) + await fetchHttpHandler.handle(mockHttpRequest).catch((error) => { + expect(String(error)).toContain( + "TypeError: Request cannot be constructed from a URL that includes credentials" + ); + }); const mockAuth = `${mockHttpRequest.username}:${mockHttpRequest.password}`; const expectedUrl = `${mockHttpRequest.protocol}//${mockAuth}@${mockHttpRequest.hostname}/`; diff --git a/packages/node-http-handler/src/server.mock.ts b/packages/node-http-handler/src/server.mock.ts index 5cc09c40f40..a904cd0034e 100644 --- a/packages/node-http-handler/src/server.mock.ts +++ b/packages/node-http-handler/src/server.mock.ts @@ -27,7 +27,9 @@ const setResponseBody = (response: ServerResponse, body: string | NodeJsRuntimeB export const createResponseFunction = (httpResp: HttpResponse) => (request: IncomingMessage, response: ServerResponse) => { response.statusCode = httpResp.statusCode; - response.statusMessage = httpResp.reason; + if (httpResp.reason) { + response.statusMessage = httpResp.reason; + } setResponseHeaders(response, httpResp.headers); setResponseBody(response, httpResp.body); }; @@ -35,7 +37,9 @@ export const createResponseFunction = export const createResponseFunctionWithDelay = (httpResp: HttpResponse, delay: number) => (request: IncomingMessage, response: ServerResponse) => { response.statusCode = httpResp.statusCode; - response.statusMessage = httpResp.reason; + if (httpResp.reason) { + response.statusMessage = httpResp.reason; + } setResponseHeaders(response, httpResp.headers); timing.setTimeout(() => setResponseBody(response, httpResp.body), delay); };