|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
| 17 | +import fs from 'fs'; |
17 | 18 | import path from 'path'; |
18 | 19 | import { spawn } from 'child_process'; |
19 | 20 | import { test, expect } from '@playwright/test'; |
@@ -59,6 +60,33 @@ async function runCli(...args: string[]): Promise<CliResult> { |
59 | 60 | }); |
60 | 61 | } |
61 | 62 |
|
| 63 | +test('--help prints usage information', async ({}) => { |
| 64 | + const result = await runCli('--help'); |
| 65 | + expect(result.exitCode).toBe(0); |
| 66 | + expect(result.output).toContain('playwright-cli'); |
| 67 | + expect(result.output).toContain('Usage:'); |
| 68 | + expect(result.output).toContain('open'); |
| 69 | + expect(result.output).toContain('snapshot'); |
| 70 | + expect(result.output).toContain('close'); |
| 71 | +}); |
| 72 | + |
| 73 | +test('--version prints version', async ({}) => { |
| 74 | + const result = await runCli('--version'); |
| 75 | + expect(result.exitCode).toBe(0); |
| 76 | + expect(result.output).toMatch(/\d+\.\d+/); |
| 77 | +}); |
| 78 | + |
| 79 | +test('install --skills creates skill files', async ({}) => { |
| 80 | + const result = await runCli('install', '--skills'); |
| 81 | + expect(result.exitCode).toBe(0); |
| 82 | + |
| 83 | + const skillPath = path.join(test.info().outputPath(), '.claude', 'skills', 'playwright-cli', 'SKILL.md'); |
| 84 | + expect(fs.existsSync(skillPath)).toBe(true); |
| 85 | + |
| 86 | + const content = fs.readFileSync(skillPath, 'utf-8'); |
| 87 | + expect(content).toContain('playwright-cli'); |
| 88 | +}); |
| 89 | + |
62 | 90 | test('open data URL', async ({}) => { |
63 | 91 | expect(await runCli('open', 'data:text/html,hello', '--persistent')).toEqual(expect.objectContaining({ |
64 | 92 | output: expect.stringContaining('hello'), |
|
0 commit comments