Skip to content

Commit d15a309

Browse files
avivsinaiclaude
andcommitted
test: add test for unknown command handling
Added test to verify that unknown commands properly fail with exit code 1 and display an appropriate error message, ensuring consistent CLI behavior. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c95ff32 commit d15a309

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/cli/test/cli-parsing.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,19 @@ describe('CLI argument parsing', () => {
101101
expect([0, 1]).toContain(result.exitCode);
102102
});
103103

104+
it('should handle unknown commands with error', async () => {
105+
const result = await runCLI(['unknowncommand'], { cwd: fixture.dir });
106+
107+
// Should exit with error code 1
108+
expect(result.exitCode).toBe(1);
109+
110+
// Should show some error output (not checking exact text to avoid brittleness)
111+
const output = result.stdout + result.stderr;
112+
expect(output.length).toBeGreaterThan(0);
113+
// Just verify it mentions the unknown command somehow
114+
expect(output.toLowerCase()).toContain('unknowncommand');
115+
});
116+
104117
it('should handle traditional command syntax', async () => {
105118
createTestFiles(fixture.dir, {
106119
'src/index.ts': 'console.log("Test");'

0 commit comments

Comments
 (0)