Skip to content

Commit b1269ed

Browse files
committed
fix(e2e): type $fetch using globalThis instead
1 parent a3daf6e commit b1269ed

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/core/server.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export async function startServer(options: StartServerOptions = {}) {
3838
for (let i = 0; i < 150; i++) {
3939
await new Promise(resolve => setTimeout(resolve, 100))
4040
try {
41-
const res = await $fetch(ctx.nuxt!.options.app.baseURL, { responseType: 'text' }) as string
41+
const res = await $fetch<string>(ctx.nuxt!.options.app.baseURL, { responseType: 'text' })
4242
if (!res.includes('__NUXT_LOADING__')) {
4343
return
4444
}
@@ -78,10 +78,9 @@ export function fetch(path: string, options?: RequestInit) {
7878
return _fetch(url(path), options)
7979
}
8080

81-
// TODO: fix type inference of `$fetch`
82-
export function $fetch(path: string, options?: FetchOptions) {
81+
export const $fetch = (function(path: string, options?: FetchOptions) {
8382
return _$fetch(url(path), options)
84-
}
83+
}) as typeof globalThis['$fetch']
8584

8685
export function url(path: string) {
8786
const ctx = useTestContext()

0 commit comments

Comments
 (0)