addressing-pr-review-c…
Address all valid review comments on a PR for the current branch in the streamlit/streamlit repo. Covers both inline review comments and general PR (issue)…
Diagnose and fix flaky Playwright e2e tests. Use when tests fail intermittently, show timeout errors, have snapshot mismatches, or exhibit browser-specific failures.
$ npx -y skills add streamlit/streamlit --skill fixing-flaky-e2e-tests --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/fixing-flaky-e2e-testsContext preview
The summary Claude sees to decide when to auto-load this skill.
Diagnose and fix flaky Playwright e2e tests. Use when tests fail intermittently, show timeout errors, have snapshot mismatches, or exhibit browser-specific failures.
name: fixing-flaky-e2e-tests description: Diagnose and fix flaky Playwright e2e tests. Use when tests fail intermittently, show timeout errors, have snapshot mismatches, or exhibit browser-specific failures.
Diagnose and fix flaky Playwright E2E tests in `e2e_playwright/`.
Run the script to identify the most flaky tests from recent CI runs:
uv run scripts/fetch_flaky_tests.py
Options:
The script downloads `playwright_test_stats` artifacts from successful `playwright.yml` runs and aggregates tests that required reruns.
Skip tests already marked with `@pytest.mark.flaky`---these are known flaky tests being tracked separately.
# Check if a test file has the flaky marker grep -l "pytest.mark.flaky" e2e_playwright/<test_file>.py
**IMPORTANT**: Only attempt to fix tests that fail locally. If you cannot reproduce the flakiness after 25 runs, do NOT attempt a fix—the test may be flaky due to CI environment factors that cannot be addressed locally.
Run the test up to 25 times with the affected browser(s). The loop breaks on first failure and captures full output:
for i in {1..25}; do
result=$(make run-e2e-test e2e_playwright/test_file.py::test_name -- --browser firefox 2>&1)
if echo "$result" | grep -q "FAILED"; then
echo "=== FAILURE ON RUN $i ==="
echo "$result"
break
fi
echo "Run $i: PASSED"
doneIf all 25 runs pass, skip this test and move to the next one.
After failure, examine:
**For persistent snapshot flakiness**: If a test keeps failing due to snapshot mismatches, compare the actual vs expected images in `e2e_playwright/test-results/snapshot-updates/`. Look for:
This helps identify whether the flakiness is due to timing (content not loaded), animation state, or browser rendering differences.
**Symptom**: Screenshots taken before element fully renders, animations not complete.
**Fix**: Add explicit waits before interactions or screenshots:
# Before element.click() assert_snapshot(element, name="snapshot") # After element.click() expect(element).to_be_visible() # Wait for visibility assert_snapshot(element, name="snapshot")
For popups/modals/calendars that animate:
calendar = page.get_by_test_id("stDateInputCalendar").first
expect(calendar).to_be_visible() # Wait for animation to complete
assert_snapshot(calendar, name="calendar-snapshot")**Symptom**: Assertion expects exact count but gets more (e.g., `assert 44 == 41`).
**Fix**: Use `>=` instead of `==` when browsers may retry failed operations:
# Before assert error_count == expected_count # After - browsers may retry failed image loads assert error_count >= expected_count
**Symptom**: `TimeoutError` on slower browsers.
**Fix**: Increase timeout for operations that can be slow:
# Before wait_until(app, lambda: check_condition(), timeout=10000) # After wait_until(app, lambda: check_condition(), timeout=20000)
**Symptom**: `Snapshot mismatch for ... (X pixels difference)`.
**Causes**:
**Fix**: Ensure element is stable before screenshot:
element = page.locator(".my-element")
expect(element).to_be_visible()
# For elements with animations, wait for specific CSS state:
expect(element).to_have_css("opacity", "1")
assert_snapshot(element, name="snapshot")For elements containing images, wait for images to be fully loaded and decoded:
from e2e_playwright.shared.app_utils import wait_for_images_loaded
element = page.locator(".my-element")
wait_for_images_loaded(element) # Waits for load + decode
assert_snapshot(element, name="snapshot")| Browser | Common Issues | |---------|---------------| | **Firefox** | Slower console logging, may retry failed requests, subpixel rendering differences | | **Webkit** | May have timing differences with layout | | **Chromium** | Generally most reliable, use as baseline |
**Symptom**: Firefox screenshots flake with 1-pixel differences due to subpixel rendering variations.
**Fix**: Add a one-liner markdown element above the element being tested. This shifts the subpixel position to a more stable value:
# In the test app (.py file)
st.markdown("---") # Stabilizes subpixel rendering for elements below
st.date_input("Pick a date")This is a workaround for Firefox's subpixel rendering behavior and can reduce snapshot flakiness when other timing fixes don't help.
If you've exhausted timing fixes and the flakiness persists only on a specific browser due to known browser limitations (not test bugs), `skip_browser` may be a
Repo: streamlit/streamlit
Address all valid review comments on a PR for the current branch in the streamlit/streamlit repo. Covers both inline review comments and general PR (issue)…
Assesses whether branch or PR changes are high-risk for externally hosted or embedded Streamlit usage and recommends whether external e2e coverage with…
Validates all code changes before committing by running format, lint, type, and unit test checks. Use after making backend (Python) or frontend (TypeScript)…
Creates a draft pull request on GitHub with proper labels, branch naming, and description formatting. Use when changes are ready to be submitted as a PR to the…
Debug Streamlit frontend and backend changes using make debug with hot-reload. Use when testing code changes, investigating bugs, checking UI behavior, or…
Lists available make commands for Streamlit development. Use for build, test, lint, or format tasks.