Skip to content

Commit ff3c8b8

Browse files
fix(local): fix run command test to use rest params and Promise return type
The buildCommand wrapper consumes the async generator internally, so loader() returns a plain async function. Tests must spread args as individual parameters (matching Stricli's variadic positional convention) and await the Promise directly.
1 parent 9104325 commit ff3c8b8

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

test/commands/local/run.test.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { CliError, ValidationError } from "../../../src/lib/errors.js";
1212
type RunFunc = (
1313
this: unknown,
1414
flags: { port: number; host: string },
15-
args: string[]
16-
) => Promise<unknown>;
15+
...args: string[]
16+
) => Promise<void>;
1717

1818
function makeContext() {
1919
return {
@@ -28,7 +28,7 @@ describe("sentry local run", () => {
2828
const func = (await runCommand.loader()) as unknown as RunFunc;
2929
const ctx = makeContext();
3030
try {
31-
await func.call(ctx, { port: 0, host: "localhost" }, []);
31+
await func.call(ctx, { port: 0, host: "localhost" });
3232
expect.unreachable("should have thrown");
3333
} catch (err) {
3434
expect(err).toBeInstanceOf(ValidationError);
@@ -40,25 +40,22 @@ describe("sentry local run", () => {
4040
const func = (await runCommand.loader()) as unknown as RunFunc;
4141
const ctx = makeContext();
4242

43-
// Use a high ephemeral port unlikely to conflict.
44-
// The command auto-starts a background server since none is running.
45-
// `printenv SENTRY_SPOTLIGHT` prints the var and exits 0.
4643
const port = 19_876;
47-
await func.call(ctx, { port, host: "127.0.0.1" }, [
44+
await func.call(
45+
ctx,
46+
{ port, host: "127.0.0.1" },
4847
"printenv",
49-
"SENTRY_SPOTLIGHT",
50-
]);
51-
// If we got here without error, the child exited 0 and env vars were set.
48+
"SENTRY_SPOTLIGHT"
49+
);
5250
});
5351

5452
test("propagates non-zero exit code as CliError", async () => {
5553
const func = (await runCommand.loader()) as unknown as RunFunc;
5654
const ctx = makeContext();
5755

58-
// `false` is a POSIX command that always exits with code 1.
5956
const port = 19_877;
6057
try {
61-
await func.call(ctx, { port, host: "127.0.0.1" }, ["false"]);
58+
await func.call(ctx, { port, host: "127.0.0.1" }, "false");
6259
expect.unreachable("should have thrown");
6360
} catch (err) {
6461
expect(err).toBeInstanceOf(CliError);

0 commit comments

Comments
 (0)