Use when asked to create or update integration tests for any Flet control in sdk/python/packages/flet/integration_tests, including visual goldens and interactive behavior tests.
Use this skill when adding, updating, or reviewing integration tests for a Flet control (core, material, cupertino, theme, services, types, or examples).
Use it for:
Pick the closest existing suite first:
sdk/python/packages/flet/integration_tests/controls/coresdk/python/packages/flet/integration_tests/controls/materialsdk/python/packages/flet/integration_tests/controls/cupertinosdk/python/packages/flet/integration_tests/controls/themesdk/python/packages/flet/integration_tests/controls/typessdk/python/packages/flet/integration_tests/controls/servicessdk/python/packages/flet/integration_tests/examplesPrefer adding tests to an existing file for the same control. Create a new test file only when no suitable file exists.
Do not mix loop_scope="module" and loop_scope="function" tests in the same file.
Naming convention:
test_<control>.py for module-scoped visual/stable tests (uses flet_app)test_<control>_isolated.py for function-scoped tests that require a fresh app per test (uses flet_app_function)Use fixtures from integration_tests/conftest.py:
flet_app (loop_scope="module"): best for stable visual tests and bulk screenshot tests.flet_app_function (loop_scope="function"): best for tests that mutate state and must run in a separate app each.theme_mode explicitly when visuals matterrequest.node.name can be used as screenshot key.FLET_TEST_GOLDEN=1 and re-run without golden mode.await flet_app.assert_control_screenshot(
request.node.name,
control,
)
flet_app_function.assert_screenshot(
request.node.name,
await flet_app_function.page.take_screenshot(
pixel_ratio=flet_app_function.screenshots_pixel_ratio
),
)
finder = await flet_app_function.tester.find_by_tooltip("Info tooltip")
assert finder.count == 1
test_<control>.py)import pytest
import flet as ft
import flet.testing as ftt
@pytest.mark.asyncio(loop_scope="module")
async def test_<behavior>(flet_app: ftt.FletTestApp, request):
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app.assert_control_screenshot(
request.node.name,
ft.Container(width=240, height=80, alignment=ft.Alignment.CENTER),
)
test_<control>_isolated.py)import pytest
import flet as ft
import flet.testing as ftt
@pytest.mark.asyncio(loop_scope="function")
async def test_<behavior>(flet_app_function: ftt.FletTestApp):
flet_app_function.page.add(ft.IconButton(icon=ft.Icons.INFO, tooltip="Info"))
await flet_app_function.tester.pump_and_settle()
finder = await flet_app_function.tester.find_by_tooltip("Info")
assert finder.count == 1
Run one test file:
uv run pytest -s -o log_cli=true -o log_cli_level=INFO packages/flet/integration_tests/controls/core/test_control.py
Run a subset:
uv run pytest -s -o log_cli=true -o log_cli_level=INFO packages/flet/integration_tests/controls/core/test_control.py -k test_visible
Generate or update goldens:
FLET_TEST_GOLDEN=1 uv run pytest -s -o log_cli=true -o log_cli_level=INFO packages/flet/integration_tests/controls/core/test_control.py
module and function scope tests are in separate files.test_<control>_isolated.py naming convention.request.node.name preferred).sdk/python/packages/flet/integration_tests/README.mdsdk/python/packages/flet/integration_tests/conftest.pysdk/python/packages/flet/integration_tests/controls/core/test_control.pysdk/python/packages/flet/integration_tests/controls/core/test_control_isolated.pysdk/python/packages/flet/integration_tests/controls/core/test_layout_control.pysdk/python/packages/flet/integration_tests/examples/core/test_control.pysdk/python/examples/controls/control