UNPKG

@nuxt/test-utils

Version:

Test utilities for Nuxt

21 lines (20 loc) 651 B
import { p as useTestContext, t as $fetch } from "./server-CmohcsAP.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) { filepath = resolve(useTestContext().options.rootDir, filepath); return `/__nuxt_component_test__/?${stringifyQuery({ path: filepath, props: JSON.stringify(props) })}`; } //#endregion export { $fetchComponent, componentTestUrl };