Skip to content

Commit 6792eba

Browse files
committed
test(env): add snap test for vp env off/on mode switching
Verifies the full system-first mode lifecycle: - `vp run` uses project's engines.node in managed mode - `vp env off` switches to system-first mode - `vp run` uses system Node.js instead of project version - `vp env on` restores managed mode
1 parent f763568 commit 6792eba

3 files changed

Lines changed: 61 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "command-env-off-on",
3+
"version": "1.0.0",
4+
"private": true,
5+
"engines": {
6+
"node": "20.18.0"
7+
},
8+
"scripts": {
9+
"check-node": "node -e \"console.log(process.version)\""
10+
}
11+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
> vp run check-node # Managed mode: should use project's engines.node (20.18.0)
2+
VITE+ - The Unified Toolchain for the Web
3+
4+
$ node -e "console.log(process.version)" ⊘ cache disabled
5+
v<semver>
6+
7+
8+
> vp env off # Switch to system-first mode
9+
VITE+ - The Unified Toolchain for the Web
10+
11+
✓ Node.js management set to system-first.
12+
13+
All vp commands and shims will now prefer system Node.js, falling back to managed if not found.
14+
15+
Run `vp env on` to always use Vite+ managed Node.js.
16+
17+
> vp run check-node # System-first mode: should use system Node.js, not project's 20.18.0
18+
VITE+ - The Unified Toolchain for the Web
19+
20+
$ node -e "console.log(process.version)" ⊘ cache disabled
21+
v<semver>
22+
23+
24+
> vp env on # Switch back to managed mode
25+
VITE+ - The Unified Toolchain for the Web
26+
27+
✓ Node.js management set to managed.
28+
29+
All vp commands and shims will now always use Vite+ managed Node.js.
30+
31+
Run `vp env off` to prefer system Node.js instead.
32+
33+
> vp run check-node # Managed mode restored: should use project's engines.node again
34+
VITE+ - The Unified Toolchain for the Web
35+
36+
$ node -e "console.log(process.version)" ⊘ cache disabled
37+
v<semver>
38+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"serial": true,
3+
"ignoredPlatforms": ["win32"],
4+
"commands": [
5+
"vp run check-node # Managed mode: should use project's engines.node (20.18.0)",
6+
"vp env off # Switch to system-first mode",
7+
"vp run check-node # System-first mode: should use system Node.js, not project's 20.18.0",
8+
"vp env on # Switch back to managed mode",
9+
"vp run check-node # Managed mode restored: should use project's engines.node again"
10+
],
11+
"after": ["vp env on"]
12+
}

0 commit comments

Comments
 (0)