[READ-ONLY] Mirror of https://github.com/danielroe/nuxt-vitest. An vitest environment with support for testing code that needs a Nuxt runtime environment
nuxt nuxt-module testing unit-testing vitest
0

Configure Feed

Select the types of activity you want to include in your feed.

chore: lint

Anthony Fu (Jan 13, 2023, 3:05 PM +0100) 9e680761 18e996ba

+10 -9
+10 -9
src/config.ts
··· 4 4 import autoImportMock from './modules/auto-import-mock' 5 5 6 6 export interface GetVitestConfigOptions { 7 - nuxt: Nuxt, 8 - viteConfig: InlineConfig, 7 + nuxt: Nuxt 8 + viteConfig: InlineConfig 9 9 } 10 10 11 11 // https://github.com/nuxt/framework/issues/6496 ··· 38 38 }).finally(() => nuxt.close()) 39 39 } 40 40 41 - export async function getVitestConfig(options?: GetVitestConfigOptions): Promise< 42 - InlineConfig & { test: VitestConfig } 43 - > { 44 - if (!options) 45 - options = await getNuxtAndViteConfig() 41 + export async function getVitestConfig( 42 + options?: GetVitestConfigOptions 43 + ): Promise<InlineConfig & { test: VitestConfig }> { 44 + if (!options) options = await getNuxtAndViteConfig() 46 45 47 46 return { 48 47 ...options.viteConfig, ··· 56 55 // additional deps 57 56 'vue', 58 57 'vitest-environment-nuxt', 59 - ...options.nuxt.options.build.transpile.filter(r => typeof r === 'string' || r instanceof RegExp) as Array<string | RegExp>, 58 + ...(options.nuxt.options.build.transpile.filter( 59 + r => typeof r === 'string' || r instanceof RegExp 60 + ) as Array<string | RegExp>), 60 61 ], 61 62 }, 62 63 }, 63 64 } 64 65 } 65 - 66 + 66 67 export async function defineConfigWithNuxtEnv(config: InlineConfig = {}) { 67 68 return defineConfig(async () => { 68 69 return mergeConfig(await getVitestConfig(), config)