UNPKG

@nuxt/test-utils

Version:
22 lines (21 loc) 669 B
import { p as useTestContext, t as $fetch } from "./server-CgIHV0e5.mjs"; import { stringifyQuery } from "ufo"; import "ofetch"; import { resolve } from "pathe"; //#region src/experimental.ts /** * This is a function to render a component directly with the Nuxt server. */ function $fetchComponent(filepath, props) { return $fetch(componentTestUrl(filepath, props)); } function componentTestUrl(filepath, props) { const ctx = useTestContext(); filepath = resolve(ctx.options.rootDir, filepath); return `/__nuxt_component_test__/?${stringifyQuery({ path: filepath, props: JSON.stringify(props) })}`; } //#endregion export { $fetchComponent, componentTestUrl };