From cad8f5af06a3039734b29513d0c47ffa6c0737be Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 21 Sep 2022 10:13:12 +0100 Subject: [PATCH] fix(test-utils): handle vitest v0.20 --- packages/test-utils/src/run.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/test-utils/src/run.ts b/packages/test-utils/src/run.ts index 094b14845dd..80678aeae5e 100644 --- a/packages/test-utils/src/run.ts +++ b/packages/test-utils/src/run.ts @@ -21,14 +21,20 @@ export async function runTests (opts: RunTestOptions) { process.env.NUXT_TEST_DEV = 'true' } + // TODO: add `as typeof import('vitest/dist/node')` and remove workaround + // when we upgrade vitest: see https://github.com/nuxt/framework/issues/6297 + // @ts-ignore missing types const { startVitest } = await import('vitest/dist/node.mjs') - const succeeded = await startVitest( + const args: any[] = [ [] /* argv */, // Vitest options { root: opts.rootDir, - run: !opts.watch + run: !opts.watch, + deps: { + inline: [/@nuxt\/test-utils/] + } }, // Vite options { @@ -36,7 +42,9 @@ export async function runTests (opts: RunTestOptions) { tsconfigRaw: '{}' } } - ) + ] + if (startVitest.length >= 4) { args.unshift('test') } + const succeeded = await startVitest(...args) if (!succeeded) { process.exit(1)