create-flet-control-integration-tests

Creates integration tests with golden screenshots for Flet controls using pytest.

16.6k|685|Updated Mar 24, 2022
One-click install
npx skills add https://github.com/flet-dev/flet --skill create-flet-control-integration-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-flet-control-integration-tests
Source: https://github.com/flet-dev/flet/tree/main/.agents/skills/create-flet-control-integration-tests
Command: npx skills add https://github.com/flet-dev/flet --skill create-flet-control-integration-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing consistent integration tests for Flet UI controls requires knowing the correct test placement, fixture scopes, screenshot assertion patterns, and golden regeneration workflow, which are easy to get wrong without guidance.

Core Features & Use Cases

  • Test Placement Rules: Directs tests to the correct suite (core, material, cupertino, theme, services, types, examples) and enforces the module-scope vs function-scope file split.
  • Assertion Patterns: Provides templates for visual screenshot assertions, full-page assertions, and functional finder-based assertions.
  • Golden Workflow: Documents how to run tests and regenerate golden screenshots with FLET_TEST_GOLDEN=1.
  • Use Case: When adding a regression test for a Flet button hover behavior, use this Skill to pick the right file, fixture, and assertion pattern, then generate updated goldens.

Quick Start

Create an integration test for the Flet IconButton tooltip behavior following the project's testing conventions.

Frequently Asked Questions about create-flet-control-integration-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write integration tests for Flet controls?

Write async pytest tests using the flet_app or flet_app_function fixtures from integration_tests/conftest.py. Use assert_control_screenshot for visual checks and tester finders like find_by_tooltip for functional assertions.

How do I generate golden screenshots for Flet tests?

Run the target test file with the FLET_TEST_GOLDEN=1 environment variable to generate or update goldens, then re-run without it to verify. Only regenerate goldens for intentional visual changes.

What is the difference between flet_app and flet_app_function fixtures?

flet_app uses loop_scope="module" and suits stable visual and bulk screenshot tests, while flet_app_function uses loop_scope="function" for tests that mutate state and need a fresh app per test. The two scopes must not be mixed in one file.

Where should Flet control integration tests be placed?

Place tests in the suite matching the control area under sdk/python/packages/flet/integration_tests/controls, such as core, material, cupertino, theme, services, or types. Prefer adding to an existing file for the same control.

Why do Flet screenshot tests fail intermittently?

Flaky screenshot tests usually come from non-deterministic content such as random values, time-varying data, or unset theme modes and sizes. Set theme_mode explicitly and use fixed sizes, padding, and spacing for deterministic rendering.