{"id":21815,"library":"pytest-textual-snapshot","title":"pytest-textual-snapshot","description":"Snapshot testing plugin for pytest that enables visual regression testing of Textual terminal applications. Version 1.1.0 requires Python >=3.8.1, <4.0.0. Regular releases.","status":"active","version":"1.1.0","language":"python","source_language":"en","source_url":"https://github.com/darrenburns/pytest-textual-snapshot","tags":["testing","pytest","textual","snapshot"],"install":[{"cmd":"pip install pytest-textual-snapshot","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Plugin requires pytest to run.","package":"pytest","optional":false},{"reason":"Plugin requires Textual framework to snapshot applications.","package":"textual","optional":false}],"imports":[{"note":"snapshot_app is provided by the plugin, not by textual itself","wrong":"from textual.testing import snapshot_app","symbol":"snapshot_app","correct":"from pytest_textual_snapshot import snapshot_app"}],"quickstart":{"code":"import pytest\nfrom textual.app import App, ComposeResult\nfrom textual.widgets import Static\nfrom pytest_textual_snapshot import snapshot_app\n\nclass SimpleApp(App):\n    def compose(self) -> ComposeResult:\n        yield Static(\"Hello, World!\")\n\ndef test_snapshot(snapshot_app):\n    app = SimpleApp()\n    async with app.run_test() as pilot:\n        # Use snapshot_app fixture to capture the app's render\n        snapshot_app(app)\n","lang":"python","description":"Minimal test using the snapshot_app fixture to capture a Textual app's render."},"warnings":[{"fix":"Ensure the test is async and uses `async with app.run_test() as pilot:` before calling snapshot_app.","message":"The snapshot_app fixture must be used within an async context (e.g., app.run_test()) otherwise it will fail.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set fixed terminal dimensions in your test using `app.run_test(size=(80, 24))` to ensure reproducibility.","message":"Snapshots are stored as SVG files in a `__snapshots__` directory. If the test environment differs (e.g., different terminal width), snapshots may mismatch.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install the package: `pip install pytest-textual-snapshot`; then import as `from pytest_textual_snapshot import snapshot_app`.","cause":"The package is not installed or incorrectly imported.","error":"ModuleNotFoundError: No module named 'pytest_textual_snapshot'"},{"fix":"Ensure you pass your app instance: `snapshot_app(app)`.","cause":"Calling snapshot_app without passing the Textual app instance.","error":"TypeError: snapshot_app() missing 1 required positional argument: 'app'"},{"fix":"Upgrade Textual: `pip install -U textual` and ensure the test is async: `async with app.run_test() as pilot:`.","cause":"Using an older version of Textual that does not have run_test method or not using an async context.","error":"AttributeError: 'App' object has no attribute 'run_test'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}