From 8e71e4298c4bfcdf167026018887999568c8405c Mon Sep 17 00:00:00 2001 From: Angel Mendez Date: Wed, 13 Dec 2023 08:20:38 -0600 Subject: [PATCH] refactor: replace got with node-fetch on functions-invoke.test.ts (#6232) replace got with node-fetch related to #5695 Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../functions-invoke/functions-invoke.test.ts | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/integration/commands/functions-invoke/functions-invoke.test.ts b/tests/integration/commands/functions-invoke/functions-invoke.test.ts index cc30f216a82..fa63e84d25c 100644 --- a/tests/integration/commands/functions-invoke/functions-invoke.test.ts +++ b/tests/integration/commands/functions-invoke/functions-invoke.test.ts @@ -1,4 +1,4 @@ -import got from 'got' +import fetch from 'node-fetch' import { describe, expect, test } from 'vitest' import { FixtureTestContext, setupFixtureTests } from '../../utils/fixture.js' @@ -39,26 +39,25 @@ describe('functions:invoke command', () => { ) test.concurrent('should serve helpful tips and tricks', async ({ devServer, fixture }) => { - const plainTextResponse = await got(`http://localhost:${devServer.port}/.netlify/functions/scheduled-isc-body`, { - throwHttpErrors: false, - retry: { limit: 0 }, - }) + const textResponse = await fetch(`http://localhost:${devServer.port}/.netlify/functions/scheduled-isc-body`, {}) + + const bodyPlainTextResponse = await textResponse.text() const youReturnedBodyRegex = /.*Your function returned `body`. Is this an accident\?.*/ - expect(plainTextResponse.body).toMatch(youReturnedBodyRegex) - expect(plainTextResponse.body).toMatch(/.*You performed an HTTP request.*/) - expect(plainTextResponse.statusCode).toBe(200) + expect(bodyPlainTextResponse).toMatch(youReturnedBodyRegex) + expect(bodyPlainTextResponse).toMatch(/.*You performed an HTTP request.*/) + expect(textResponse.status).toBe(200) - const htmlResponse = await got(`http://localhost:${devServer.port}/.netlify/functions/scheduled-isc-body`, { - throwHttpErrors: false, - retry: { limit: 0 }, + const htmlResponse = await fetch(`http://localhost:${devServer.port}/.netlify/functions/scheduled-isc-body`, { headers: { accept: 'text/html', }, }) - expect(htmlResponse.body).toMatch(/.*