Commit 4abd51e4 authored by Jimmy Lai's avatar Jimmy Lai

Fix fetch server response test types

parent 84801c43
...@@ -34,11 +34,12 @@ describe('fetchServerResponse output export fallback', () => { ...@@ -34,11 +34,12 @@ describe('fetchServerResponse output export fallback', () => {
const originalOutput = process.env.__NEXT_CONFIG_OUTPUT const originalOutput = process.env.__NEXT_CONFIG_OUTPUT
const originalFetch = global.fetch const originalFetch = global.fetch
const originalLocation = global.location const originalLocation = global.location
const processEnv = process.env as Record<string, string | undefined>
beforeEach(() => { beforeEach(() => {
process.env.NODE_ENV = 'production' processEnv.NODE_ENV = 'production'
process.env.__NEXT_CONFIG_OUTPUT = 'export' processEnv.__NEXT_CONFIG_OUTPUT = 'export'
global.location = new URL('https://example.com/') as Location global.location = new URL('https://example.com/') as unknown as Location
setNavigationBuildId('build-id') setNavigationBuildId('build-id')
mockCreateFromReadableStream.mockReset() mockCreateFromReadableStream.mockReset()
mockFetchOutputExportFallbackResponse.mockReset() mockFetchOutputExportFallbackResponse.mockReset()
...@@ -47,8 +48,8 @@ describe('fetchServerResponse output export fallback', () => { ...@@ -47,8 +48,8 @@ describe('fetchServerResponse output export fallback', () => {
}) })
afterEach(() => { afterEach(() => {
process.env.NODE_ENV = originalNodeEnv processEnv.NODE_ENV = originalNodeEnv
process.env.__NEXT_CONFIG_OUTPUT = originalOutput processEnv.__NEXT_CONFIG_OUTPUT = originalOutput
global.fetch = originalFetch global.fetch = originalFetch
global.location = originalLocation global.location = originalLocation
jest.restoreAllMocks() jest.restoreAllMocks()
...@@ -72,11 +73,11 @@ describe('fetchServerResponse output export fallback', () => { ...@@ -72,11 +73,11 @@ describe('fetchServerResponse output export fallback', () => {
) )
global.fetch = jest global.fetch = jest
.fn<typeof fetch>() .fn(async () => initialMiss)
.mockResolvedValueOnce(initialMiss) .mockImplementationOnce(async () => initialMiss)
.mockImplementation(async () => { .mockImplementation(async () => {
throw new Error('unexpected extra fetch') throw new Error('unexpected extra fetch')
}) }) as typeof fetch
mockFetchOutputExportFallbackResponse.mockResolvedValue({ mockFetchOutputExportFallbackResponse.mockResolvedValue({
response: fallbackResponse, response: fallbackResponse,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment