-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Description
Summary
The CLI integration tests currently use Tcl expect scripts (tests/cli-tests/*.expect). These should be migrated to vitest using child_process.execFile, matching the rest of the test suite.
Motivation
The recent names→aliases refactoring (#59) required updating all 28 .expect files — version checks, command renames, flag changes, and a fragile help-text string comparison. This highlighted several pain points:
- Wrong language: Tests are written in Tcl, while the project is TypeScript
- No shared utilities: Every script duplicates wallet setup/teardown boilerplate
- Fragile matching: The help text test does character-by-character comparison with hardcoded spacing
- No integration with vitest: Separate test runner, separate JUnit XML generation, separate CI configuration
expectis overkill: None of the tests use interactive TTY features (prompts, password input) — they just spawn a command and check stdout
Proposed approach
Use vitest with a thin wrapper around child_process.execFile:
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';
const exec = promisify(execFile);
const archon = (...args: string[]) => exec('bash', ['archon', ...args]);
describe('alias commands', () => {
let did: string;
beforeAll(async () => {
await archon('new-wallet');
const { stdout } = await archon('create-id', '-r', 'local', 'test');
did = stdout.trim();
});
afterAll(async () => {
await exec('bash', ['admin', 'reset-db']);
});
it('add-alias / list-aliases / remove-alias', async () => {
await archon('add-alias', 'qa', did);
const { stdout } = await archon('list-aliases');
expect(JSON.parse(stdout)).toHaveProperty('qa', did);
await archon('remove-alias', 'qa');
const { stdout: after } = await archon('list-aliases');
expect(JSON.parse(after)).not.toHaveProperty('qa');
});
});Benefits
- Same language, same runner, same reporting as unit tests
- Shared
beforeAll/afterAllreplaces copy-pasted Tcl blocks - Real assertions instead of regex + timeouts
vitest --reporter=junitreplaces the manual JUnit XML generator inrun_cli_tests.sh- Still integration tests — spawns the real CLI binary against the real server
Scope
- Migrate all 28
.expectscripts to vitest test files - Remove
run_cli_tests.shand thecli-tests/directory - Update CI to run CLI tests as part of the standard vitest suite
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels