Skip to content

Commit 389c932

Browse files
test(runtime): expect npm --version probe in command pack install
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 6870dc5 commit 389c932

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

packages/runtime/tests/command-packs.test.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ fs.appendFileSync(
5858
}) + "\\n",
5959
);
6060
61+
if (args[0] === "--version") {
62+
process.stdout.write("10.0.0\\n");
63+
process.exit(0);
64+
}
65+
6166
const manifestPath = path.join(cwd, "package.json");
6267
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
6368
manifest.dependencies ??= {};
@@ -205,8 +210,9 @@ test("installs once on success and restores the previous version after validatio
205210
env: Record<string, string | null>;
206211
},
207212
);
208-
expect(successfulCalls).toHaveLength(1);
209-
expect(successfulCalls[0]?.env).toEqual({
213+
// runNpm probes `npm --version` before each install/uninstall.
214+
expect(successfulCalls.map((call) => call.args[0])).toEqual(["--version", "install"]);
215+
expect(successfulCalls[1]?.env).toEqual({
210216
registry: "https://registry.example.test",
211217
catalog: null,
212218
recursive: null,
@@ -228,14 +234,11 @@ test("installs once on success and restores the previous version after validatio
228234
env: Record<string, string | null>;
229235
},
230236
);
231-
expect(rollbackCalls).toHaveLength(2);
232-
expect(rollbackCalls[0]?.args.slice(0, 2)).toEqual([
233-
"install",
234-
"@ali/bailian-plugin-agent@broken",
235-
]);
236-
expect(rollbackCalls[1]?.args.slice(0, 2)).toEqual([
237-
"install",
238-
"@ali/bailian-plugin-agent@1.0.0",
237+
expect(rollbackCalls.map((call) => call.args.slice(0, 2))).toEqual([
238+
["--version"],
239+
["install", "@ali/bailian-plugin-agent@broken"],
240+
["--version"],
241+
["install", "@ali/bailian-plugin-agent@1.0.0"],
239242
]);
240243

241244
const manifest = JSON.parse(

0 commit comments

Comments
 (0)