Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 3, 2026

Implements visual regression testing using github.com/charmbracelet/x/exp/golden to prevent unintended formatting changes in console output components (tables, boxes, trees, error messages).

Changes

  • Golden test suite (pkg/console/golden_test.go)

    • 44 golden files covering 10 rendering categories
    • Table rendering: simple, titled, totaled, wide, empty variants
    • Box rendering: narrow/medium/wide widths, emoji content
    • Tree rendering: flat, nested, deep hierarchies (up to 5 levels)
    • Error formatting: basic, with hints, with source context
    • Message formatting: success, info, warning, error, location, command, progress
    • Layout composition: multi-element combinations
  • Makefile target: make update-golden regenerates golden files after intentional formatting changes

  • Documentation (specs/visual-regression-testing.md)

    • Usage patterns and golden file organization
    • TTY vs non-TTY output handling
    • Failure diagnosis with diff examples

Example

func TestGolden_TableRendering(t *testing.T) {
    config := TableConfig{
        Headers: []string{"Name", "Status", "Duration"},
        Rows: [][]string{
            {"test-1", "success", "1.2s"},
            {"test-2", "failed", "0.5s"},
        },
    }
    output := RenderTable(config)
    golden.RequireEqual(t, []byte(output))
}

Golden files capture plain-text output (non-TTY) for consistency across environments. Tests fail with unified diff when rendering changes unexpectedly.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 4d63.com
    • Triggering command: `/update-job-proxy /update-job-proxy l/linux_amd64/cocommit /usr/bin/infocmp-m /usr/lib/git-corComplete visual regression testing implementation

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> http�� ithub-script/git/ref/tags/v8 infocmp 6/x64/bin/node t/gh-aw/git/ref/git go` (dns block)

  • Triggering command: /update-job-proxy /update-job-proxy DROP e1fb8a9a git -c 1cc9d80b66b8db84--stdin fetch /home/dependabot--alternate-refs --depth=1 %H %ct %D 4ea7f6d9 git -c tformat fetch /bin/git 7af297/shallow.l/usr/sbin/ip6tables origin 0 /usr/bin/git (dns block)
  • cloud.google.com
    • Triggering command: `/update-job-proxy /update-job-proxy l/linux_amd64/cocommit /usr/bin/infocmp-m /usr/lib/git-corComplete visual regression testing implementation

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> http�� ithub-script/git/ref/tags/v8 infocmp 6/x64/bin/node t/gh-aw/git/ref/git go` (dns block)

  • Triggering command: /update-job-proxy /update-job-proxy DROP e1fb8a9a git -c 1cc9d80b66b8db84--stdin fetch /home/dependabot--alternate-refs --depth=1 %H %ct %D 4ea7f6d9 git -c tformat fetch /bin/git 7af297/shallow.l/usr/sbin/ip6tables origin 0 /usr/bin/git (dns block)
  • codeberg.org
    • Triggering command: `/update-job-proxy /update-job-proxy l/linux_amd64/cocommit /usr/bin/infocmp-m /usr/lib/git-corComplete visual regression testing implementation

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> http�� ithub-script/git/ref/tags/v8 infocmp 6/x64/bin/node t/gh-aw/git/ref/git go` (dns block)

  • Triggering command: /update-job-proxy /update-job-proxy DROP e1fb8a9a git -c 1cc9d80b66b8db84--stdin fetch /home/dependabot--alternate-refs --depth=1 %H %ct %D 4ea7f6d9 git -c tformat fetch /bin/git 7af297/shallow.l/usr/sbin/ip6tables origin 0 /usr/bin/git (dns block)
  • dev.gaijin.team
    • Triggering command: `/update-job-proxy /update-job-proxy l/linux_amd64/cocommit /usr/bin/infocmp-m /usr/lib/git-corComplete visual regression testing implementation

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> http�� ithub-script/git/ref/tags/v8 infocmp 6/x64/bin/node t/gh-aw/git/ref/git go` (dns block)

  • Triggering command: /update-job-proxy /update-job-proxy DROP e1fb8a9a git -c 1cc9d80b66b8db84--stdin fetch /home/dependabot--alternate-refs --depth=1 %H %ct %D 4ea7f6d9 git -c tformat fetch /bin/git 7af297/shallow.l/usr/sbin/ip6tables origin 0 /usr/bin/git (dns block)
  • gitlab.com
    • Triggering command: `/update-job-proxy /update-job-proxy l/linux_amd64/cocommit /usr/bin/infocmp-m /usr/lib/git-corComplete visual regression testing implementation

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> http�� ithub-script/git/ref/tags/v8 infocmp 6/x64/bin/node t/gh-aw/git/ref/git go` (dns block)

  • Triggering command: /update-job-proxy /update-job-proxy DROP e1fb8a9a git -c 1cc9d80b66b8db84--stdin fetch /home/dependabot--alternate-refs --depth=1 %H %ct %D 4ea7f6d9 git -c tformat fetch /bin/git 7af297/shallow.l/usr/sbin/ip6tables origin 0 /usr/bin/git (dns block)
  • go-simpler.org
    • Triggering command: `/update-job-proxy /update-job-proxy l/linux_amd64/cocommit /usr/bin/infocmp-m /usr/lib/git-corComplete visual regression testing implementation

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> http�� ithub-script/git/ref/tags/v8 infocmp 6/x64/bin/node t/gh-aw/git/ref/git go` (dns block)

  • Triggering command: /update-job-proxy /update-job-proxy DROP e1fb8a9a git -c 1cc9d80b66b8db84--stdin fetch /home/dependabot--alternate-refs --depth=1 %H %ct %D 4ea7f6d9 git -c tformat fetch /bin/git 7af297/shallow.l/usr/sbin/ip6tables origin 0 /usr/bin/git (dns block)
  • go.augendre.info
    • Triggering command: `/update-job-proxy /update-job-proxy l/linux_amd64/cocommit /usr/bin/infocmp-m /usr/lib/git-corComplete visual regression testing implementation

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> http�� ithub-script/git/ref/tags/v8 infocmp 6/x64/bin/node t/gh-aw/git/ref/git go` (dns block)

  • Triggering command: /update-job-proxy /update-job-proxy DROP e1fb8a9a git -c 1cc9d80b66b8db84--stdin fetch /home/dependabot--alternate-refs --depth=1 %H %ct %D 4ea7f6d9 git -c tformat fetch /bin/git 7af297/shallow.l/usr/sbin/ip6tables origin 0 /usr/bin/git (dns block)
  • go.googlesource.com
    • Triggering command: `/update-job-proxy /update-job-proxy l/linux_amd64/cocommit /usr/bin/infocmp-m /usr/lib/git-corComplete visual regression testing implementation

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> http�� ithub-script/git/ref/tags/v8 infocmp 6/x64/bin/node t/gh-aw/git/ref/git go` (dns block)

  • Triggering command: /update-job-proxy /update-job-proxy DROP e1fb8a9a git -c 1cc9d80b66b8db84--stdin fetch /home/dependabot--alternate-refs --depth=1 %H %ct %D 4ea7f6d9 git -c tformat fetch /bin/git 7af297/shallow.l/usr/sbin/ip6tables origin 0 /usr/bin/git (dns block)
  • go.opentelemetry.io
    • Triggering command: `/update-job-proxy /update-job-proxy l/linux_amd64/cocommit /usr/bin/infocmp-m /usr/lib/git-corComplete visual regression testing implementation

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> http�� ithub-script/git/ref/tags/v8 infocmp 6/x64/bin/node t/gh-aw/git/ref/git go` (dns block)

  • Triggering command: /update-job-proxy /update-job-proxy DROP e1fb8a9a git -c 1cc9d80b66b8db84--stdin fetch /home/dependabot--alternate-refs --depth=1 %H %ct %D 4ea7f6d9 git -c tformat fetch /bin/git 7af297/shallow.l/usr/sbin/ip6tables origin 0 /usr/bin/git (dns block)
  • go.uber.org
    • Triggering command: `/update-job-proxy /update-job-proxy l/linux_amd64/cocommit /usr/bin/infocmp-m /usr/lib/git-corComplete visual regression testing implementation

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> http�� ithub-script/git/ref/tags/v8 infocmp 6/x64/bin/node t/gh-aw/git/ref/git go` (dns block)

  • Triggering command: /update-job-proxy /update-job-proxy DROP e1fb8a9a git -c 1cc9d80b66b8db84--stdin fetch /home/dependabot--alternate-refs --depth=1 %H %ct %D 4ea7f6d9 git -c tformat fetch /bin/git 7af297/shallow.l/usr/sbin/ip6tables origin 0 /usr/bin/git (dns block)
  • go.yaml.in
    • Triggering command: `/update-job-proxy /update-job-proxy l/linux_amd64/cocommit /usr/bin/infocmp-m /usr/lib/git-corComplete visual regression testing implementation

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> http�� ithub-script/git/ref/tags/v8 infocmp 6/x64/bin/node t/gh-aw/git/ref/git go` (dns block)

  • Triggering command: /update-job-proxy /update-job-proxy DROP e1fb8a9a git -c 1cc9d80b66b8db84--stdin fetch /home/dependabot--alternate-refs --depth=1 %H %ct %D 4ea7f6d9 git -c tformat fetch /bin/git 7af297/shallow.l/usr/sbin/ip6tables origin 0 /usr/bin/git (dns block)
  • google.golang.org
    • Triggering command: `/update-job-proxy /update-job-proxy l/linux_amd64/cocommit /usr/bin/infocmp-m /usr/lib/git-corComplete visual regression testing implementation

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> http�� ithub-script/git/ref/tags/v8 infocmp 6/x64/bin/node t/gh-aw/git/ref/git go` (dns block)

  • Triggering command: /update-job-proxy /update-job-proxy DROP e1fb8a9a git -c 1cc9d80b66b8db84--stdin fetch /home/dependabot--alternate-refs --depth=1 %H %ct %D 4ea7f6d9 git -c tformat fetch /bin/git 7af297/shallow.l/usr/sbin/ip6tables origin 0 /usr/bin/git (dns block)
  • gopkg.in
    • Triggering command: `/update-job-proxy /update-job-proxy l/linux_amd64/cocommit /usr/bin/infocmp-m /usr/lib/git-corComplete visual regression testing implementation

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> http�� ithub-script/git/ref/tags/v8 infocmp 6/x64/bin/node t/gh-aw/git/ref/git go` (dns block)

  • Triggering command: /update-job-proxy /update-job-proxy DROP e1fb8a9a git -c 1cc9d80b66b8db84--stdin fetch /home/dependabot--alternate-refs --depth=1 %H %ct %D 4ea7f6d9 git -c tformat fetch /bin/git 7af297/shallow.l/usr/sbin/ip6tables origin 0 /usr/bin/git (dns block)
  • honnef.co
    • Triggering command: `/update-job-proxy /update-job-proxy l/linux_amd64/cocommit /usr/bin/infocmp-m /usr/lib/git-corComplete visual regression testing implementation

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> http�� ithub-script/git/ref/tags/v8 infocmp 6/x64/bin/node t/gh-aw/git/ref/git go` (dns block)

  • Triggering command: /update-job-proxy /update-job-proxy DROP e1fb8a9a git -c 1cc9d80b66b8db84--stdin fetch /home/dependabot--alternate-refs --depth=1 %H %ct %D 4ea7f6d9 git -c tformat fetch /bin/git 7af297/shallow.l/usr/sbin/ip6tables origin 0 /usr/bin/git (dns block)
  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login -json GO111MODULE ux-amd64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE rg/toolchain@v0.-s GOINSECURE GOMOD GOMODCACHE go (http block)
  • mvdan.cc
    • Triggering command: `/update-job-proxy /update-job-proxy l/linux_amd64/cocommit /usr/bin/infocmp-m /usr/lib/git-corComplete visual regression testing implementation

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com> http�� ithub-script/git/ref/tags/v8 infocmp 6/x64/bin/node t/gh-aw/git/ref/git go` (dns block)

  • Triggering command: /update-job-proxy /update-job-proxy DROP e1fb8a9a git -c 1cc9d80b66b8db84--stdin fetch /home/dependabot--alternate-refs --depth=1 %H %ct %D 4ea7f6d9 git -c tformat fetch /bin/git 7af297/shallow.l/usr/sbin/ip6tables origin 0 /usr/bin/git (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Add visual regression tests with golden files</issue_title>
<issue_description>## Objective

Implement visual regression testing for console output components using github.com/charmbracelet/x/exp/golden to prevent formatting regressions.

Context

The Terminal Stylist analysis (#8747) recommended adding visual regression tests to validate that console output rendering remains consistent across code changes, particularly for tables, boxes, and tree structures.

Approach

  1. Add github.com/charmbracelet/x/exp/golden dependency
  2. Create test directory structure for golden files (e.g., pkg/console/testdata/)
  3. Write tests for key console components:
    • Table rendering with different terminal widths
    • Box rendering with various content lengths
    • Tree rendering with deep hierarchies
    • Error formatting with context
  4. Generate initial golden files with current output
  5. Add test helper functions for common golden test patterns
  6. Document how to update golden files when output intentionally changes

Files to Create/Modify

  • Create: pkg/console/golden_test.go - Golden file tests
  • Create: pkg/console/testdata/ - Directory for golden files
  • Update: go.mod - Add golden testing dependency
  • Update: Makefile - Add target to update golden files
  • Create: specs/visual-regression-testing.md - Documentation

Acceptance Criteria

  • Golden tests exist for table rendering
  • Golden tests exist for box rendering
  • Golden tests exist for tree rendering
  • Golden tests exist for error formatting
  • Tests fail when output format changes unexpectedly
  • Documentation explains how to update golden files
  • Makefile target exists to regenerate golden files
  • Tests cover different terminal widths
  • Tests validate both TTY and non-TTY output

Example Test

func TestTableRenderingGolden(t *testing.T) {
    config := console.TableConfig{
        Headers: []string{"Name", "Status", "Duration"},
        Rows: [][]string{
            {"test-1", "success", "1.2s"},
            {"test-2", "failed", "0.5s"},
        },
    }
    output := console.RenderTable(config)
    golden.RequireEqual(t, []byte(output))
}

Related to #8748

AI generated by Plan Command for discussion #8747

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 3, 2026 21:03
- Add github.com/charmbracelet/x/exp/golden dependency
- Create pkg/console/testdata/ directory structure
- Implement comprehensive golden tests for console rendering:
  * Table rendering (simple, titled, totaled, wide, empty)
  * Box rendering (various widths and content)
  * Tree rendering (single, flat, nested, deep hierarchies)
  * Error formatting (basic, with hints, with context)
  * Message formatting (success, info, warning, error, location)
  * Layout composition (multiple element combinations)
- Add Makefile target 'update-golden' for regenerating golden files
- Create specs/visual-regression-testing.md documentation
- Generate 44 initial golden files covering all rendering components

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot AI changed the title [WIP] Add visual regression tests using golden files Add visual regression tests with golden files for console rendering Jan 3, 2026
Copilot AI requested a review from mnkiefer January 3, 2026 21:13
@pelikhan pelikhan marked this pull request as ready for review January 3, 2026 21:29
@pelikhan pelikhan merged commit 3804e33 into main Jan 3, 2026
129 of 130 checks passed
@pelikhan pelikhan deleted the copilot/add-visual-regression-tests branch January 3, 2026 21:29
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.

[plan] Add visual regression tests with golden files

3 participants