Skip to content

Conversation

@hoteye
Copy link

@hoteye hoteye commented Oct 20, 2025

Summary

Implements visual regression testing using ink-visual-testing to automatically detect UI changes and prevent visual regressions.

Changes

πŸ”§ Setup

  • βœ… Install ink-visual-testing package (v1.0.1)
  • βœ… Create .ink-visual.config.js with terminal size presets
  • βœ… Update .gitignore to exclude temporary test outputs

πŸ§ͺ Test Infrastructure

  • βœ… Create visual test files using file path mode (tests/visual/*.tsx)
  • βœ… Add src/ui.visual.test.tsx with 6 test scenarios
  • βœ… Generate baseline images for all game states

πŸ“Š Test Coverage

Game States:

  • midgame - Game in progress with partial guesses
  • win - Winning state with "You win!" message
  • lose - Losing state showing the correct word

Multi-board Games:

  • dual-board - Two boards simultaneously (120Γ—30 terminal)
  • triple-board - Three boards simultaneously (160Γ—35 terminal)

Initial State:

  • fresh-start - New game starting state

Terminal Sizes: 80Γ—24, 120Γ—30, 160Γ—35

πŸ“œ NPM Scripts

npm run test:visual         # Run visual tests
npm run test:visual:watch   # Watch mode
npm run test:visual:update  # Update baselines

πŸ“Έ Baseline Images

Generated 6 PNG baselines (136KB total):

  • midgame.png (17KB) - Shows game in progress with colored letter hints
  • win.png (18KB) - Shows "You win!" with all green letters
  • lose.png (25KB) - Shows failure message with correct word
  • dual-board.png (21KB) - Two game boards side by side
  • triple-board.png (27KB) - Three game boards
  • fresh-start.png (14KB) - Clean game board

πŸ“– Documentation

  • βœ… Add comprehensive VISUAL_TESTING.md guide with:
    • Setup instructions
    • Usage examples
    • Troubleshooting tips
    • Best practices

Test Results

All tests passing with 0 pixel difference:

βœ… Diff pixels: 0 (allowed: 100)
βœ“ 6 tests passed in 17.91s

Technical Details

Uses file path mode instead of component mode:

  • Each test scenario has a corresponding TypeScript file in tests/visual/
  • Files render the App component with specific states and exitPlease: true
  • Supports custom components, context providers, and complex interactions
  • Captures complete terminal output correctly

Benefits

✨ Prevents visual regressions - Automatically detects unintended UI changes
πŸ” Easy review - Visual diffs show exactly what changed
⚑ Fast feedback - Runs in ~18 seconds
πŸ“¦ CI-ready - Can be integrated into CI/CD pipelines
🎯 Comprehensive - Covers all game states and layouts

Test Plan

  • Run visual tests locally - all passing
  • Verify baseline images are correct
  • Check documentation is complete
  • Confirm .gitignore excludes temp files
  • Validate npm scripts work correctly

πŸ€– Generated with ai ,my english is so pool.

Implements visual regression testing to detect UI changes automatically.

## Changes

### Setup
- Install ink-visual-testing package (v1.0.1)
- Create .ink-visual.config.js with terminal size presets
- Update .gitignore to exclude temporary test outputs

### Test Infrastructure
- Create visual test files using file path mode (tests/visual/*.tsx)
- Add ui.visual.test.tsx with 6 test scenarios
- Generate baseline images for all game states

### Test Coverage
- Game states: midgame, win, lose
- Multi-board: dual-board, triple-board
- Initial state: fresh-start
- Different terminal sizes: 80Γ—24, 120Γ—30, 160Γ—35

### NPM Scripts
- npm run test:visual - Run visual tests
- npm run test:visual:watch - Watch mode
- npm run test:visual:update - Update baselines

### Documentation
- Add VISUAL_TESTING.md with comprehensive guide

## Baseline Images
Generated 6 PNG baselines (136KB total):
- midgame.png, win.png, lose.png
- dual-board.png, triple-board.png
- fresh-start.png

All tests passing with 0 pixel diff.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant