-
Notifications
You must be signed in to change notification settings - Fork 483
Description
Overview
Terraform CDK CLI has multiple UI rendering issues that could be prevented with automated visual regression testing. Since CDKTF already uses Ink framework and has , implementing visual regression testing would be a natural next step to ensure consistent CLI experience.
Evidence of Current UI Problems
Multiple open issues demonstrate recurring UI rendering problems:
Animation & Display Issues
-
cdktf-cli: disable animations via flag #2951: "disable animations via flag" - CI environments show broken spinner animations:
-
CLI: Fixed width output on deploy is unusable #3503: "Fixed width output on deploy is unusable" - Text wrapping makes output unreadable
-
CLI UX: Nicer output for
cdktf synthif there are no stacks in an app #2793: "Nicer output for cdktf synth if there are no stacks" - Output formatting improvements needed -
CDKTF CLI: CLI hangs if in interactive input is required during CDKTF commands #3041: "CLI hangs if interactive input is required" - Interactive component issues
Technical Context
CDKTF CLI already uses rich Ink ecosystem:
- (v3.2.0) - Main UI framework
- (v4.0.3) - Loading animations
- (v4.2.2) - Selection components
- (v3.1.0) - Table displays
- (v2.1.0) - Existing testing foundation
Proposed Solution: Enhanced Visual Testing
I recommend implementing ink-visual-testing alongside the existing for comprehensive UI testing.
Why ink-visual-testing for CDKTF?
- ✅ Perfect compatibility: Works with Ink v3+ (CDKTF uses v3.2.0)
- ✅ CI-focused: Specifically designed to solve CI animation issues like cdktf-cli: disable animations via flag #2951
- ✅ Easy integration: Complements existing setup
- ✅ Cross-platform consistency: Bundled fonts ensure identical rendering across environments
- ✅ Real terminal rendering: Uses node-pty for accurate CLI simulation
Implementation Benefits
- Solve CI animation issues (cdktf-cli: disable animations via flag #2951) - Detect broken spinner rendering automatically
- Prevent layout problems (CLI: Fixed width output on deploy is unusable #3503) - Catch width/wrapping issues before release
- Ensure component stability - Verify ink-table, ink-select-input display correctly
- Cross-platform consistency - Identical rendering on Mac/Linux/Windows/CI
- Release confidence - Visual baselines prevent UI regressions
Example Implementation
import { fixedPtyRender, getCIOptimizedConfig } from 'ink-visual-testing';
// Test main CDKTF CLI commands
describe('CDKTF CLI Visual Tests', () => {
it('should render help command correctly', async () => {
await fixedPtyRender(
'./dist/bin/cdktf.js',
'./tests/__output__/help-command.png',
{
...getCIOptimizedConfig(), // Solves CI animation issues
args: ['--help'],
cols: 120,
rows: 40
}
);
});
it('should handle synth output properly', async () => {
await fixedPtyRender(
'./dist/bin/cdktf.js',
'./tests/__output__/synth-command.png',
{
...getCIOptimizedConfig(),
args: ['synth'],
cols: 100,
rows: 30
}
);
});
});Recommended Test Coverage
- Core commands:
cdktf deploy,cdktf synth,cdktf init - Interactive components: Selection prompts, confirmation dialogs
- Progress displays: Spinners, progress bars, status tables
- Error states: Error messages, warnings, validation output
- Different terminal sizes: Narrow (80 cols) to wide (120+ cols)
- CI environment: Animation-free rendering for automation
Integration with Existing Testing
Visual testing would complement existing tools:
- ink-testing-library: Continue for unit/component testing
- ink-visual-testing: Add for integration/regression testing
- Jest: Orchestrate both types of tests
// Existing unit test (keep these)
import { render } from 'ink-testing-library';
// New visual test (add these)
import { visualTest } from 'ink-visual-testing';
describe('Deploy Command', () => {
// Unit test - fast, logic verification
it('should render deploy status', () => {
const { lastFrame } = render(<DeployStatus status="deploying" />);
expect(lastFrame()).toContain('Deploying');
});
// Visual test - end-to-end, regression protection
it('should display deploy output correctly', async () => {
await visualTest('deploy-output', './fixtures/deploy-command.tsx', {
cols: 100,
rows: 25
});
});
});Technical Support Offer
I'm the author of ink-visual-testing and would be happy to provide comprehensive technical support for implementing visual regression testing in CDKTF:
- Integration guidance - Help set up visual tests alongside existing ink-testing-library
- CI optimization - Specifically address cdktf-cli: disable animations via flag #2951 animation issues in CI environments
- Baseline establishment - Assist with creating initial visual baselines for key commands
- Performance optimization - Ensure tests run efficiently in CI/CD pipelines
- Component-specific testing - Handle complex Ink components like tables and spinners
Expected Impact
- Solve CI animation issues (cdktf-cli: disable animations via flag #2951) through consistent, animation-free CI rendering
- Prevent layout regressions (CLI: Fixed width output on deploy is unusable #3503) with automated width/formatting checks
- Improve developer confidence with visual baselines for UI changes
- Better user experience through consistent CLI appearance across platforms
- Faster debugging of UI issues with visual diff images
Next Steps
If you're interested in exploring this approach, I'm available for:
- Technical discussion on integration strategy
- Demo/proof of concept implementation
- Documentation and best practices guidance
- Long-term maintenance and support
This would significantly enhance CDKTF's reliability and solve existing UI pain points while building on your current testing infrastructure.
Note: ink-visual-testing successfully prevents similar UI issues in other Ink-based CLIs. It's specifically designed to work alongside ink-testing-library for comprehensive testing coverage.