Skip to content

Commit 759becf

Browse files
Coly010FrozenPandaz
authored andcommitted
fix(vite): support passing --watch to inferred vitest commands (#23298)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior <!-- This is the behavior we have today --> We currently do not handle passing `--watch` when running inferred `vitest` commands ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> We should support handling `--watch` ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #23185 (cherry picked from commit 7cf09a6)
1 parent 963d2e0 commit 759becf

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

packages/vite/src/plugins/__snapshots__/plugin-vitest.spec.ts.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ exports[`@nx/vite/plugin root project should create nodes 1`] = `
88
"targets": {
99
"test": {
1010
"cache": true,
11-
"command": "vitest run",
11+
"command": "vitest",
1212
"inputs": [
1313
"default",
1414
"^production",
@@ -20,6 +20,7 @@ exports[`@nx/vite/plugin root project should create nodes 1`] = `
2020
],
2121
"options": {
2222
"cwd": ".",
23+
"watch": false,
2324
},
2425
"outputs": [
2526
"{projectRoot}/coverage",

packages/vite/src/plugins/__snapshots__/plugin-with-test.spec.ts.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ exports[`@nx/vite/plugin with test node root project should create nodes - with
88
"targets": {
99
"test": {
1010
"cache": true,
11-
"command": "vitest run",
11+
"command": "vitest",
1212
"inputs": [
1313
"default",
1414
"^production",
@@ -20,6 +20,7 @@ exports[`@nx/vite/plugin with test node root project should create nodes - with
2020
],
2121
"options": {
2222
"cwd": ".",
23+
"watch": false,
2324
},
2425
"outputs": [
2526
"{projectRoot}/coverage",

packages/vite/src/plugins/plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ async function testTarget(
215215
projectRoot: string
216216
) {
217217
return {
218-
command: `vitest run`,
219-
options: { cwd: joinPathFragments(projectRoot) },
218+
command: `vitest`,
219+
options: { cwd: joinPathFragments(projectRoot), watch: false },
220220
cache: true,
221221
inputs: [
222222
...('production' in namedInputs

0 commit comments

Comments
 (0)