Skip to content

Commit

Permalink
fix: drop whatwg-fetch polyfill and update to nuxt v3.7 (nuxt#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Aug 29, 2023
1 parent 2603259 commit de959c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions src/vitest-environment-nuxt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,11 @@ export default <Environment>{
}

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
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/nuxt-vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit de959c9

Please sign in to comment.