From eff6096a0dcde562d6097c1df894b39a3f4dfa6c Mon Sep 17 00:00:00 2001 From: Ninad Sheth Date: Wed, 23 Oct 2024 14:07:24 +0530 Subject: [PATCH] Fixed tests --- packages/cli-build/test/id.test.js | 6 ++++-- packages/cli-exec/test/ping.test.js | 6 ++++-- packages/cli-exec/test/stop.test.js | 14 ++++++-------- packages/core/src/network.js | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/cli-build/test/id.test.js b/packages/cli-build/test/id.test.js index b7aa14c73..ef37a0c20 100644 --- a/packages/cli-build/test/id.test.js +++ b/packages/cli-build/test/id.test.js @@ -29,7 +29,8 @@ describe('percy build:id', () => { expect(logger.stderr).toEqual([]); expect(logger.stdout).toEqual(['123']); - expect(percyServer.requests).toEqual([['/percy/healthcheck']]); + expect(percyServer.requests.length).toEqual(1); + expect(percyServer.requests[0][0]).toEqual('/percy/healthcheck'); }); it('can call the /percy/healthcheck endpoint at an alternate port', async () => { @@ -40,7 +41,8 @@ describe('percy build:id', () => { expect(logger.stderr).toEqual([]); expect(logger.stdout).toEqual(['456']); - expect(percyServer.requests).toEqual([['/percy/healthcheck']]); + expect(percyServer.requests.length).toEqual(1); + expect(percyServer.requests[0][0]).toEqual('/percy/healthcheck'); }); it('logs an error when the endpoint errors', async () => { diff --git a/packages/cli-exec/test/ping.test.js b/packages/cli-exec/test/ping.test.js index b1273a806..d9bfa67b1 100644 --- a/packages/cli-exec/test/ping.test.js +++ b/packages/cli-exec/test/ping.test.js @@ -34,7 +34,8 @@ describe('percy exec:ping', () => { expect(logger.stderr).toEqual([]); expect(logger.stdout).toEqual(['[percy] Percy is running']); - expect(percyServer.requests).toEqual([['/percy/healthcheck']]); + expect(percyServer.requests.length).toEqual(1); + expect(percyServer.requests[0][0]).toEqual('/percy/healthcheck'); }); it('can ping /percy/healthcheck at an alternate port', async () => { @@ -46,7 +47,8 @@ describe('percy exec:ping', () => { expect(logger.stderr).toEqual([]); expect(logger.stdout).toEqual(['[percy] Percy is running']); - expect(percyServer.requests).toEqual([['/percy/healthcheck']]); + expect(percyServer.requests.length).toEqual(1); + expect(percyServer.requests[0][0]).toEqual('/percy/healthcheck'); }); it('logs an error when the endpoint errors', async () => { diff --git a/packages/cli-exec/test/stop.test.js b/packages/cli-exec/test/stop.test.js index bc6db7f6d..dd958c5dc 100644 --- a/packages/cli-exec/test/stop.test.js +++ b/packages/cli-exec/test/stop.test.js @@ -24,10 +24,9 @@ describe('percy exec:stop', () => { await stop(); - expect(percyServer.requests).toEqual([ - ['/percy/stop'], - ['/percy/healthcheck'] - ]); + expect(percyServer.requests.length).toEqual(2); + expect(percyServer.requests[0][0]).toEqual('/percy/stop'); + expect(percyServer.requests[1][0]).toEqual('/percy/healthcheck'); expect(logger.stderr).toEqual([]); expect(logger.stdout).toEqual(['[percy] Percy has stopped']); @@ -54,10 +53,9 @@ describe('percy exec:stop', () => { await stop(['--port=4567']); - expect(percyServer.requests).toEqual([ - ['/percy/stop'], - ['/percy/healthcheck'] - ]); + expect(percyServer.requests.length).toEqual(2); + expect(percyServer.requests[0][0]).toEqual('/percy/stop'); + expect(percyServer.requests[1][0]).toEqual('/percy/healthcheck'); expect(logger.stderr).toEqual([]); expect(logger.stdout).toEqual(['[percy] Percy has stopped']); diff --git a/packages/core/src/network.js b/packages/core/src/network.js index 9a5bc9dae..2ec510d0a 100644 --- a/packages/core/src/network.js +++ b/packages/core/src/network.js @@ -414,7 +414,7 @@ async function sendResponseResource(network, request, session) { // Make a new request with Node based on a network request async function makeDirectRequest(network, request, session) { - const { cookies = [] } = await session.send('Network.getCookies', { urls: [request.url] }); + const { cookies } = await session.send('Network.getCookies', { urls: [request.url] }); let headers = { ...request.headers,