From 75b39cc68090b2e7d40e7c4c7d66fccb38018a79 Mon Sep 17 00:00:00 2001 From: Angel Mendez Date: Thu, 30 Nov 2023 11:24:53 -0600 Subject: [PATCH] refactor: replace got with node-fetch on scheduled-functions.test.ts replace got with node-fetch related to #5695 --- .../commands/dev/scheduled-functions.test.ts | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/tests/integration/commands/dev/scheduled-functions.test.ts b/tests/integration/commands/dev/scheduled-functions.test.ts index 7475332d072..27f62494e0e 100644 --- a/tests/integration/commands/dev/scheduled-functions.test.ts +++ b/tests/integration/commands/dev/scheduled-functions.test.ts @@ -1,27 +1,23 @@ import { describe, expect, test } from 'vitest' import { FixtureTestContext, setupFixtureTests } from '../../utils/fixture.js' -import got from '../../utils/got.js' +import fetch from 'node-fetch' import { pause } from '../../utils/pause.js' describe('scheduled functions', () => { setupFixtureTests('dev-server-with-functions', { devServer: true }, () => { test('should emulate next_run for scheduled functions', async ({ devServer }) => { - const response = await got(`http://localhost:${devServer.port}/.netlify/functions/scheduled-isc`, { - throwHttpErrors: false, - retry: { limit: 0 }, - }) + const response = await fetch(`http://localhost:${devServer.port}/.netlify/functions/scheduled-isc`, {}) - expect(response.statusCode).toBe(200) + expect(response.status).toBe(200) }) }) setupFixtureTests('dev-server-with-functions', { devServer: true }, () => { test('should detect file changes to scheduled function', async ({ devServer, fixture }) => { - const { body } = await got(`http://localhost:${devServer.port}/.netlify/functions/ping`, { - throwHttpErrors: false, - retry: { limit: 0 }, - }) + const body = await fetch(`http://localhost:${devServer.port}/.netlify/functions/ping`, {}).then((res) => + res.text(), + ) expect(body).toBe('ping') @@ -43,10 +39,9 @@ describe('scheduled functions', () => { const DETECT_FILE_CHANGE_DELAY = 500 await pause(DETECT_FILE_CHANGE_DELAY) - const { body: warning } = await got(`http://localhost:${devServer.port}/.netlify/functions/ping`, { - throwHttpErrors: false, - retry: { limit: 0 }, - }) + const warning = await fetch(`http://localhost:${devServer.port}/.netlify/functions/ping`, {}).then((res) => + res.text(), + ) expect(warning).toContain('Your function returned `body`') })