From f9c07bc14a0df053af72e38d84dcc7c3de653ee5 Mon Sep 17 00:00:00 2001 From: Angel Mendez Date: Thu, 7 Dec 2023 18:37:32 -0600 Subject: [PATCH] refactor: replace got with node-fetch on redirects.test.ts (#6234) replace got with node-fetch related to #5695 --- .../commands/dev/redirects.test.ts | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/tests/integration/commands/dev/redirects.test.ts b/tests/integration/commands/dev/redirects.test.ts index 7a3e55c480b..a4fc93aa45d 100644 --- a/tests/integration/commands/dev/redirects.test.ts +++ b/tests/integration/commands/dev/redirects.test.ts @@ -1,19 +1,16 @@ import { describe, expect, test } from 'vitest' import { FixtureTestContext, setupFixtureTests } from '../../utils/fixture.js' -import got from '../../utils/got.js' +import fetch from 'node-fetch' describe('redirects', () => { setupFixtureTests('dev-server-with-functions', { devServer: true }, () => { test('should send original query params to functions', async ({ devServer }) => { - const response = await got(`http://localhost:${devServer.port}/with-params?param2=world&other=1`, { - throwHttpErrors: false, - retry: { limit: 0 }, - }) + const response = await fetch(`http://localhost:${devServer.port}/with-params?param2=world&other=1`, {}) - expect(response.statusCode).toBe(200) + expect(response.status).toBe(200) - const result = JSON.parse(response.body) + const result = await response.json() expect(result.queryStringParameters).not.toHaveProperty('param1') expect(result.queryStringParameters).toHaveProperty('param2', 'world') expect(result.queryStringParameters).toHaveProperty('other', '1') @@ -22,14 +19,11 @@ describe('redirects', () => { test('should send original query params to functions when using duplicate parameters', async ({ devServer, }) => { - const response = await got(`http://localhost:${devServer.port}/api/echo?param=hello¶m=world`, { - throwHttpErrors: false, - retry: { limit: 0 }, - }) + const response = await fetch(`http://localhost:${devServer.port}/api/echo?param=hello¶m=world`, {}) - expect(response.statusCode).toBe(200) + expect(response.status).toBe(200) - const result = JSON.parse(response.body) + const result = await response.json() expect(result.queryStringParameters).toHaveProperty('param', 'hello, world') expect(result.multiValueQueryStringParameters).toHaveProperty('param', ['hello', 'world']) })