diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/README.md b/crates/vp_cli_snapshots/tests/cli_snapshots/README.md index bba56cf886..b3fc7abf0a 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/README.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/README.md @@ -288,11 +288,16 @@ Snapshots are plain-text screen grids: styling is flattened, and redaction masks paths, durations, versions, UUIDs, thread counts, byte-size numbers (units kept: ` kB`), and content-hash asset suffixes (see `redact.rs`; sizes and hashes because output bytes differ across OSes). If -a case produces nondeterministic -output, fix it with a milestone or a redaction rule; never rerun until -green. Set +a case produces nondeterministic output, fix it with controlled fixture data, +a milestone, or a redaction rule; never rerun until green. Set `formatted-snapshot = true` on a step only when the test is about colors. +For registry fallback tests, use `local-registry = true` and a fixture +`mock-manifest.json` entry such as `"npm/latest"` to control the resolved version. +Keep the CLI input unpinned so the fallback is still tested, and keep exact +version assertions. Unmocked registry requests go upstream, so +`local-registry = true` alone does not freeze dist-tags. + Fixture trees are excluded from repo-wide fmt, lint, typecheck, and vitest (`vite.config.ts`, `tsconfig.json`); recorded snapshots and `snapshots.toml` are runner metadata and never appear inside the staged diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_install_no_arg/assert-installed-npm.cjs b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_install_no_arg/assert-installed-npm.cjs index 421650a99e..5a9c56cf37 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_install_no_arg/assert-installed-npm.cjs +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_install_no_arg/assert-installed-npm.cjs @@ -1,11 +1,12 @@ const assert = require('node:assert/strict'); const { execFileSync } = require('node:child_process'); +const manifest = require('./mock-manifest.json'); const installed = JSON.parse( execFileSync('vp', ['env', 'list', 'npm', '--json'], { encoding: 'utf8' }), ).package_managers.npm; assert.equal(installed.length, 1); -assert.match(installed[0].version, /^\d+\.\d+\.\d+/); +assert.equal(installed[0].version, manifest['npm/latest'].version); assert.equal(installed[0].current, false); assert.equal(installed[0].default, false); console.log('Standalone npm is installed but is not current'); diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_install_no_arg/mock-manifest.json b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_install_no_arg/mock-manifest.json new file mode 100644 index 0000000000..81697f5eda --- /dev/null +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_install_no_arg/mock-manifest.json @@ -0,0 +1,3 @@ +{ + "npm/latest": { "name": "npm", "version": "12.1.0" } +} diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_install_no_arg/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_install_no_arg/snapshots.toml index c4c7bcd9fd..7e754b3679 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_install_no_arg/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_install_no_arg/snapshots.toml @@ -14,6 +14,8 @@ steps = [ name = "command_env_install_standalone_npm_fallback" vp = "global" comment = "Explicit npm installation uses standalone registry npm without installing Node.js." +# Fix the registry's latest response, not the CLI input: this must exercise +# the fallback while remaining independent of future npm releases. local-registry = true skip-platforms = ["windows"] seed-runtime = false diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_install_no_arg/snapshots/command_env_install_standalone_npm_fallback.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_install_no_arg/snapshots/command_env_install_standalone_npm_fallback.md index cb6c3c9065..774316077d 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_install_no_arg/snapshots/command_env_install_standalone_npm_fallback.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_install_no_arg/snapshots/command_env_install_standalone_npm_fallback.md @@ -7,7 +7,7 @@ Explicit npm installation uses standalone registry npm without installing Node.j an explicit npm scope exports the standalone npm fallback ``` -export VP_NPM_VERSION=12.0.2 +export VP_NPM_VERSION=12.1.0 Using npm (resolved from registry fallback) ```