diff --git a/src/vitest-environment-nuxt/index.ts b/src/vitest-environment-nuxt/index.ts index be5a49256..2d2b711dc 100644 --- a/src/vitest-environment-nuxt/index.ts +++ b/src/vitest-environment-nuxt/index.ts @@ -61,15 +61,11 @@ export default { } const h3App = createApp() - - // JSDOM does not include an implementation of window.fetch. - // `globalThis.fetch` is not available here for us to use - // the native standards compliant version, and node-fetch - // has issues in combination with JSDOM so we polyfill - // with cross-fetch here for JSDOM. + if (!win.fetch) { - // @ts-ignore skip types, we only polyfill - await import('whatwg-fetch') + await import('node-fetch-native/polyfill') + // @ts-expect-error URLSearchParams is not a proeprty of window + win.URLSearchParams = globalThis.URLSearchParams } // @ts-expect-error TODO: fix in h3 diff --git a/test/fixtures/nuxt-vitest/package.json b/test/fixtures/nuxt-vitest/package.json index 4707ca663..0bf30ea9b 100644 --- a/test/fixtures/nuxt-vitest/package.json +++ b/test/fixtures/nuxt-vitest/package.json @@ -18,7 +18,7 @@ "@testing-library/vue": "7.0.0", "happy-dom": "10.11.1", "jsdom": "22.1.0", - "nuxt": "3.6.5", + "nuxt": "3.7.0", "nuxt-vitest": "0.10.2", "typescript": "5.2.2", "vitest": "0.33.0",