mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-18 02:07:14 +00:00
chore: messing around
This commit is contained in:
parent
723a55b500
commit
4bae4df057
@ -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,
|
||||
|
@ -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,9 +42,22 @@ 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()
|
||||
}
|
||||
@ -54,7 +69,6 @@ export function createTest (options: Partial<TestOptions>): TestHooks {
|
||||
if (ctx.options.server) {
|
||||
await startServer()
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx.options.waitFor) {
|
||||
await (new Promise(resolve => setTimeout(resolve, ctx.options.waitFor)))
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user