fix(test-utils): do not hide vitest output (#9442)

This commit is contained in:
Anthony Fu 2022-12-02 17:42:23 +08:00 committed by GitHub
parent 0b6f37f756
commit 3501fd5ca7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -59,12 +59,14 @@ export async function loadFixture () {
configFile: ctx.options.configFile
})
kit.logger.level = ctx.options.logLevel
await fsp.mkdir(ctx.nuxt.options.buildDir, { recursive: true })
}
export async function buildFixture () {
const ctx = useTestContext()
// Hide build info for test
const prevLevel = kit.logger.level
kit.logger.level = ctx.options.logLevel
await kit.buildNuxt(ctx.nuxt!)
kit.logger.level = prevLevel
}

View File

@ -1,10 +1,17 @@
import * as _kit from '@nuxt/kit'
import { createTest, exposeContextToEnv } from '@nuxt/test-utils'
const hooks = createTest(JSON.parse(process.env.NUXT_TEST_OPTIONS || '{}'))
// @ts-ignore type cast
const kit: typeof _kit = _kit.default || _kit
const options = JSON.parse(process.env.NUXT_TEST_OPTIONS || '{}')
const hooks = createTest(options)
export const setup = async () => {
kit.logger.info('Building Nuxt app...')
await hooks.setup()
exposeContextToEnv()
kit.logger.info('Running tests...')
}
export const teardown = async () => {