Skip to content

Commit de18110

Browse files
authored
test: adjust cleanup for next change (#405)
1 parent db5d451 commit de18110

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tests/utils/fixture.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,17 @@ export const createFixture = async (fixture: string, ctx: FixtureTestContext) =>
7676
// invocations would not use fetch-cache at all - this restores the original fetch
7777
// and makes globalThis.fetch.__nextPatched falsy which will allow Next.js to apply
7878
// needed patch
79-
// @ts-ignore fetch doesn't have __nextPatched property in types
80-
if (globalThis.fetch.__nextPatched && globalThis._nextOriginalFetch) {
81-
globalThis.fetch = globalThis._nextOriginalFetch
79+
if (
80+
// @ts-ignore fetch doesn't have __nextPatched property in types
81+
globalThis.fetch.__nextPatched &&
82+
// before https://github.com/vercel/next.js/pull/64088 original fetch was set on globalThis._nextOriginalFetch
83+
// after it it is being set on globalThis.fetch._nextOriginalFetch
84+
// so we check both to make sure tests continue to work regardless of next version
85+
// @ts-ignore fetch doesn't have _nextOriginalFetch property in types
86+
(globalThis._nextOriginalFetch || globalThis.fetch._nextOriginalFetch)
87+
) {
88+
// @ts-ignore fetch doesn't have _nextOriginalFetch property in types
89+
globalThis.fetch = globalThis._nextOriginalFetch || globalThis.fetch._nextOriginalFetch
8290
}
8391

8492
ctx.cwd = await mkdtemp(join(tmpdir(), 'netlify-next-runtime-'))

0 commit comments

Comments
 (0)