Skip to content

Commit

Permalink
fix(e2e): type $fetch using globalThis instead
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Apr 22, 2024
1 parent a3daf6e commit b1269ed
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/core/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function startServer(options: StartServerOptions = {}) {
for (let i = 0; i < 150; i++) {
await new Promise(resolve => setTimeout(resolve, 100))
try {
const res = await $fetch(ctx.nuxt!.options.app.baseURL, { responseType: 'text' }) as string
const res = await $fetch<string>(ctx.nuxt!.options.app.baseURL, { responseType: 'text' })
if (!res.includes('__NUXT_LOADING__')) {
return
}
Expand Down Expand Up @@ -78,10 +78,9 @@ export function fetch(path: string, options?: RequestInit) {
return _fetch(url(path), options)
}

// TODO: fix type inference of `$fetch`
export function $fetch(path: string, options?: FetchOptions) {
export const $fetch = (function(path: string, options?: FetchOptions) {

Check failure on line 81 in src/core/server.ts

View workflow job for this annotation

GitHub Actions / lint

Missing space before function parentheses
return _$fetch(url(path), options)
}
}) as typeof globalThis['$fetch']

export function url(path: string) {
const ctx = useTestContext()
Expand Down

0 comments on commit b1269ed

Please sign in to comment.