From 7cf09a677f6c33683330ed144b2a3d8a6249511a Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Fri, 10 May 2024 13:31:59 +0100 Subject: [PATCH] fix(vite): support passing --watch to inferred vitest commands (#23298) ## Current Behavior We currently do not handle passing `--watch` when running inferred `vitest` commands ## Expected Behavior We should support handling `--watch` ## Related Issue(s) Fixes #23185 --- .../vite/src/plugins/__snapshots__/plugin-vitest.spec.ts.snap | 3 ++- .../src/plugins/__snapshots__/plugin-with-test.spec.ts.snap | 3 ++- packages/vite/src/plugins/plugin.ts | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/plugins/__snapshots__/plugin-vitest.spec.ts.snap b/packages/vite/src/plugins/__snapshots__/plugin-vitest.spec.ts.snap index e13928dab43d8..c9b3a5b294d3a 100644 --- a/packages/vite/src/plugins/__snapshots__/plugin-vitest.spec.ts.snap +++ b/packages/vite/src/plugins/__snapshots__/plugin-vitest.spec.ts.snap @@ -8,7 +8,7 @@ exports[`@nx/vite/plugin root project should create nodes 1`] = ` "targets": { "test": { "cache": true, - "command": "vitest run", + "command": "vitest", "inputs": [ "default", "^production", @@ -20,6 +20,7 @@ exports[`@nx/vite/plugin root project should create nodes 1`] = ` ], "options": { "cwd": ".", + "watch": false, }, "outputs": [ "{projectRoot}/coverage", diff --git a/packages/vite/src/plugins/__snapshots__/plugin-with-test.spec.ts.snap b/packages/vite/src/plugins/__snapshots__/plugin-with-test.spec.ts.snap index a505b3dbad73f..8935cd251350b 100644 --- a/packages/vite/src/plugins/__snapshots__/plugin-with-test.spec.ts.snap +++ b/packages/vite/src/plugins/__snapshots__/plugin-with-test.spec.ts.snap @@ -8,7 +8,7 @@ exports[`@nx/vite/plugin with test node root project should create nodes - with "targets": { "test": { "cache": true, - "command": "vitest run", + "command": "vitest", "inputs": [ "default", "^production", @@ -20,6 +20,7 @@ exports[`@nx/vite/plugin with test node root project should create nodes - with ], "options": { "cwd": ".", + "watch": false, }, "outputs": [ "{projectRoot}/coverage", diff --git a/packages/vite/src/plugins/plugin.ts b/packages/vite/src/plugins/plugin.ts index 0147066d19db0..05859050971e9 100644 --- a/packages/vite/src/plugins/plugin.ts +++ b/packages/vite/src/plugins/plugin.ts @@ -215,8 +215,8 @@ async function testTarget( projectRoot: string ) { return { - command: `vitest run`, - options: { cwd: joinPathFragments(projectRoot) }, + command: `vitest`, + options: { cwd: joinPathFragments(projectRoot), watch: false }, cache: true, inputs: [ ...('production' in namedInputs