-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Introduced `smoke.test.ts` to verify that the CLI tool can run essential commands without errors. - Includes tests for basic CLI usage and ERD command execution, checking for expected output.
- Loading branch information
1 parent
fa41fad
commit 841863b
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { exec } from 'node:child_process' | ||
import { promisify } from 'node:util' | ||
import { beforeAll, describe, expect, it } from 'vitest' | ||
|
||
const execAsync = promisify(exec) | ||
|
||
beforeAll(async () => { | ||
await execAsync('rm -rf ./dist-cli/ ./node_modules/.tmp') | ||
await execAsync('pnpm run build:cli') | ||
}) | ||
|
||
describe('CLI Smoke Test', () => { | ||
it('should run the CLI command without errors', async () => { | ||
try { | ||
const { stdout, stderr } = await execAsync('npx --no-install . help') | ||
expect(stderr).toBe('') | ||
expect(stdout).toEqual( | ||
`Usage: liam [options] [command] | ||
CLI tool for Liam | ||
Options: | ||
-V, --version output the version number | ||
-h, --help display help for command | ||
Commands: | ||
erd ERD commands | ||
help [command] display help for command | ||
`, | ||
) | ||
} catch (error) { | ||
// Fail the test if an error occurs | ||
expect(error).toBeNull() | ||
} | ||
}) | ||
|
||
it('should run the CLI command without errors', async () => { | ||
await execAsync('rm -rf ./dist') | ||
try { | ||
const { stdout, stderr } = await execAsync( | ||
'npx --no-install . erd build --input fixtures/input.sql', | ||
) | ||
expect(stderr).toBe('') | ||
expect(stdout).toContain('building for production') | ||
expect(stdout).toContain('✓ built in') | ||
const { stdout: lsOutput } = await execAsync('ls ./dist') | ||
expect(lsOutput.trim().length).toBeGreaterThan(0) | ||
} catch (error) { | ||
// Fail the test if an error occurs | ||
expect(error).toBeNull() | ||
} finally { | ||
await execAsync('rm -rf ./dist') | ||
} | ||
}) | ||
}) |