UNPKG

@nuxt/test-utils

Version:
25 lines (22 loc) 686 B
import { resolve } from 'pathe'; import { stringifyQuery } from 'ufo'; import { $ as $fetch, u as useTestContext } from './shared/test-utils.CHPAu7TP.mjs'; import 'tinyexec'; import 'get-port-please'; import 'ofetch'; import 'node:path'; import 'defu'; import 'std-env'; function $fetchComponent(filepath, props) { return $fetch(componentTestUrl(filepath, props)); } function componentTestUrl(filepath, props) { const ctx = useTestContext(); filepath = resolve(ctx.options.rootDir, filepath); const path = stringifyQuery({ path: filepath, props: JSON.stringify(props) }); return `/__nuxt_component_test__/?${path}`; } export { $fetchComponent, componentTestUrl };