fix tests on windows
This commit is contained in:
parent
15bbfdd42f
commit
c81e550cc9
2 changed files with 36 additions and 5 deletions
|
|
@ -43,7 +43,16 @@ describe("CLI E2E Tests", () => {
|
|||
describe("invalid commands", () => {
|
||||
it("should show error for unknown command", async () => {
|
||||
try {
|
||||
await $(["unknown-command"]);
|
||||
// Add explicit timeout for Windows CI
|
||||
const result = await execaNode(
|
||||
path.resolve("dist/index.js"),
|
||||
["unknown-command"],
|
||||
{
|
||||
timeout: 5000, // 5 second timeout instead of default 10
|
||||
reject: true,
|
||||
windowsHide: true, // Prevent console window on Windows
|
||||
}
|
||||
);
|
||||
fail("Should have thrown an error");
|
||||
} catch (error: any) {
|
||||
expect(error.exitCode).not.toBe(0);
|
||||
|
|
@ -51,11 +60,20 @@ describe("CLI E2E Tests", () => {
|
|||
const errorOutput = error.message || error.stderr || error.stdout || "";
|
||||
expect(errorOutput.length).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
}, 8000); // Increase test timeout to 8 seconds
|
||||
|
||||
it("should show help on invalid flag", async () => {
|
||||
try {
|
||||
await $(["--invalid-flag"]);
|
||||
// Add explicit timeout for Windows CI
|
||||
const result = await execaNode(
|
||||
path.resolve("dist/index.js"),
|
||||
["--invalid-flag"],
|
||||
{
|
||||
timeout: 5000, // 5 second timeout instead of default 10
|
||||
reject: true,
|
||||
windowsHide: true, // Prevent console window on Windows
|
||||
}
|
||||
);
|
||||
fail("Should have thrown an error");
|
||||
} catch (error: any) {
|
||||
expect(error.exitCode).not.toBe(0);
|
||||
|
|
@ -63,6 +81,6 @@ describe("CLI E2E Tests", () => {
|
|||
const errorOutput = error.message || error.stderr || error.stdout || "";
|
||||
expect(errorOutput.length).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
}, 8000); // Increase test timeout to 8 seconds
|
||||
});
|
||||
});
|
||||
|
|
|
|||
15
src/index.ts
15
src/index.ts
|
|
@ -64,4 +64,17 @@ program
|
|||
await logout();
|
||||
});
|
||||
|
||||
program.parse();
|
||||
// Handle unknown commands
|
||||
program.on("command:*", () => {
|
||||
console.error(`Error: Unknown command '${program.args.join(" ")}'\n`);
|
||||
program.outputHelp();
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
// Parse arguments and handle errors
|
||||
try {
|
||||
program.parse();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue