chore: messing around

This commit is contained in:
Harlan Wilton 2023-03-06 23:58:02 +11:00
parent 723a55b500
commit 4bae4df057
3 changed files with 30 additions and 22 deletions

View File

@ -37,17 +37,6 @@ export const resolveRootDir = () => {
export async function loadFixture () {
const ctx = useTestContext()
const randomId = Math.random().toString(36).slice(2, 8)
const buildDir = resolve(ctx.options.rootDir, '.nuxt', randomId)
Object.assign(ctx.options.nuxtConfig, {
buildDir,
nitro: {
output: {
dir: resolve(buildDir, 'output')
}
}
})
ctx.nuxt = await kit.loadNuxt({
cwd: ctx.options.rootDir,
dev: ctx.options.dev,

View File

@ -5,6 +5,8 @@ import { createBrowser } from '../browser'
import type { TestHooks, TestOptions } from '../types'
import setupJest from './jest'
import setupVitest from './vitest'
import {resolve} from "node:path";
import {promises as fsp} from "node:fs";
export const setupMaps = {
jest: setupJest,
@ -40,20 +42,32 @@ export function createTest (options: Partial<TestOptions>): TestHooks {
const ctx = useTestContext()
ctx.options.rootDir = resolveRootDir()
if (ctx.options.dev) {
// always output to a random build dir
const randomId = Math.random().toString(36).slice(2, 8)
const buildDir = resolve(ctx.options.rootDir, '.nuxt', randomId)
Object.assign(ctx.options.nuxtConfig, {
buildDir,
nitro: {
output: {
dir: resolve(buildDir, 'output')
}
}
})
await fsp.mkdir(buildDir, { recursive: true })
if (ctx.options.devServer) {
await startDevServer()
} else {
if (ctx.options.fixture) {
await loadFixture()
}
}
if (ctx.options.fixture) {
await loadFixture()
}
if (ctx.options.build) {
await buildFixture()
}
if (ctx.options.build) {
await buildFixture()
}
if (ctx.options.server) {
await startServer()
}
if (ctx.options.server) {
await startServer()
}
if (ctx.options.waitFor) {

View File

@ -12,7 +12,12 @@ export interface TestOptions {
buildDir: string
nuxtConfig: NuxtConfig
build: boolean
/**
* @deprecated use `devServer`
*/
dev: boolean
devServer: boolean
setupTimeout: number
waitFor: number
browser: boolean