Skip to content

request: Option to visualize widget boundaries in golden test scenarios #161

@MiniSuperDev

Description

@MiniSuperDev

Is there an existing feature request for this?

  • I have searched the existing issues.

Command

Option to visualize widget boundaries in golden test scenarios

Description

Image Image

When using GoldenTestGroup, the layout is affected by the largest widget (including text of test names) in each row/column. This makes it hard to tell the actual size or constraints of each widget.

It would be super helpful to have a built-in option (maybe a debug flag or wrapper) to show widget boundaries — like drawing a border around each child — to better see margins, padding, and overall sizing.

Right now, I manually add a DecoratedBox with a white border (see “enabled 2” in the image) to simulate this. Although DecoratedBox may not be the most optimal solution, it serves to illustrate what I want.

Thanks!

This is test is for the alchemist example.

import 'package:alchemist/alchemist.dart';
import 'package:example/widgets/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  group('Red Button Golden Tests', () {
    goldenTest(
      'renders correctly',
      fileName: 'red_button',
      builder: () => GoldenTestGroup(
        children: [
          GoldenTestScenario(
            name: 'enabled',
            child: RedButton(
              onPressed: () {},
              child: const Text('Red Button'),
            ),
          ),
          GoldenTestScenario(
            name: 'enabled 2',
            child: DecoratedBox(
              decoration: BoxDecoration(
                border: Border.all(
                  color: Colors.white,
                  width: 4,
                ),
              ),
              child: RedButton(
                onPressed: () {},
                child: const Text('Red Button'),
              ),
            ),
          ),
          GoldenTestScenario(
            name: 'disabled',
            child: const RedButton(
              onPressed: null,
              child: Text('Red Button'),
            ),
          ),
          GoldenTestScenario(
            name: 'with icon',
            child: RedButton(
              onPressed: () {},
              icon: const Icon(Icons.add),
              child: const Text('Red Button'),
            ),
          ),
          GoldenTestScenario(
            name: 'disabled with icon',
            child: const RedButton(
              onPressed: null,
              icon: Icon(Icons.add),
              child: Text('Red Button'),
            ),
          ),
        ],
      ),
    );
  });
}

Reasoning

.

Additional context and comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions