test: setup

This commit is contained in:
Benjamin Canac
2024-03-06 12:40:34 +01:00
parent 8aefde231a
commit b67fddeef8
5 changed files with 476 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
import { mountSuspended } from '@nuxt/test-utils/runtime'
import path from 'path'
export default async function (nameOrHtml: string, options: any, component: any) {
let html: string
const name = path.parse(component.__file).name
if (options === undefined) {
const app = {
template: nameOrHtml,
components: { [`U${name}`]: component }
}
const result = await mountSuspended(app)
html = result.html()
} else {
const cResult = await mountSuspended(component, options)
html = cResult.html()
}
return html
}

3
test/nuxt/nuxt.config.ts Normal file
View File

@@ -0,0 +1,3 @@
export default defineNuxtConfig({
modules: ['../../src/module']
})