Skip to content

Commit

Permalink
refactor: replace got with node-fetch on redirects.test.ts (#6234)
Browse files Browse the repository at this point in the history
replace got with node-fetch

related to #5695
  • Loading branch information
hereje authored Dec 8, 2023
1 parent 2626541 commit f9c07bc
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions tests/integration/commands/dev/redirects.test.ts
Original file line number Diff line number Diff line change
@@ -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<FixtureTestContext>('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')
Expand All @@ -22,14 +19,11 @@ describe('redirects', () => {
test<FixtureTestContext>('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&param=world`, {
throwHttpErrors: false,
retry: { limit: 0 },
})
const response = await fetch(`http://localhost:${devServer.port}/api/echo?param=hello&param=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'])
})
Expand Down

1 comment on commit f9c07bc

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

  • Dependency count: 1,399
  • Package size: 405 MB
  • Number of ts-expect-error directives: 1,331

Please sign in to comment.