Skip to content

Commit

Permalink
fix(e2e): revert changes for $fetch inference to unbreak build
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Apr 17, 2024
1 parent 1636ced commit dd295d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"h3": "*",
"happy-dom": "^9.10.9 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
"jsdom": "^22.0.0 || ^23.0.0 || ^24.0.0",
"nitropack": "*",
"playwright-core": "^1.34.3",
"vite": "*",
"vitest": "^0.34.6 || ^1.0.0",
Expand Down Expand Up @@ -153,4 +154,4 @@
"node": "^14.18.0 || >=16.10.0"
},
"packageManager": "pnpm@8.15.5"
}
}
8 changes: 4 additions & 4 deletions src/core/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { getRandomPort, waitForPort } from 'get-port-please'
import type { FetchOptions } from 'ofetch'
import { $fetch as _$fetch, fetch as _fetch } from 'ofetch'
import * as _kit from '@nuxt/kit'
import type { $Fetch } from 'nitropack'
import { resolve } from 'pathe'
import { useTestContext } from './context'

Expand Down Expand Up @@ -39,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<string>(ctx.nuxt!.options.app.baseURL, { responseType: 'text' })
const res = await $fetch(ctx.nuxt!.options.app.baseURL, { responseType: 'text' }) as string
if (!res.includes('__NUXT_LOADING__')) {
return
}
Expand Down Expand Up @@ -79,9 +78,10 @@ export function fetch(path: string, options?: RequestInit) {
return _fetch(url(path), options)
}

export const $fetch = (function $fetch(path: string, options?: FetchOptions) {
// TODO: fix type inference of `$fetch`
export function $fetch(path: string, options?: FetchOptions) {
return _$fetch(url(path), options)
}) as $Fetch
}

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

0 comments on commit dd295d3

Please sign in to comment.