DEV Community

Styrow.dev
Styrow.dev

Posted on Originally published at styrow.dev

Designing a resilient test suite for a high-concurrency, real-time dashboard

🔥 Playwright Flakiness Killer:
Financial dashboard tests fail because transient "Processing..." flashes and WebSocket noise mask the final stable state. How do you assert State D without false positives?

📌 Problem Statement
High-concurrency trading dashboard. State A → Action → Transient B/C (errors/partial updates) → State D. Timing unpredictable. Background WebSocket fires irrelevant updates. Basic waits fail.

💡 Solution & Code Walkthrough
Use expect.poll() with custom timeout + page.route() to mute noise. Assert final state while ignoring intermediate flashes.

// Assert final State D while ignoring transient B/C states
await expect.poll(async () => {
  const status = await page.locator('#order-status').textContent();
  const errors = await page.locator('.transient-error').count();
  return { status, errors };
}, { timeout: 30000 }).toBe({ status: 'Success', errors: 0 });
Enter fullscreen mode Exit fullscreen mode

Mute WebSocket noise:

// Mute irrelevant background WebSocket noise during critical action
await page.route('**/ws/feed', route => route.abort());
Enter fullscreen mode Exit fullscreen mode

🔑 Key Takeaways
expect.poll() retries until condition met or timeout
• Assert absence of transient errors alongside final state
• Route/abort irrelevant WebSocket events during critical window
• Never use brittle waitForSelector for state transitions

❓ Quick Summary Q&A
Q: Why not waitForSelector? A: It catches intermediate states, causing flakiness.
Q: How to handle WebSocket noise? A: Intercept and abort non-critical feeds during the action window.

TAGS: playwright, testing, automation, resilience, websocket

────────────────────────────────────────
📲 Download the app:
App Store: ────────────────────────────────────────

📲 𝐅𝐑𝐄𝐄 𝐌𝐎𝐁𝐈𝐋𝐄 𝐀𝐏𝐏 — 𝟔𝟎𝟎+ 𝐒𝐃𝐄𝐓 𝐐&𝐀𝐬
Practice real-world interview scenarios offline on the free QA Automation & SDET Prep app:

🤖 𝐆𝐨𝐨𝐠𝐥𝐞 𝐏𝐥𝐚𝐲 (𝐀𝐧𝐝𝐫𝐨𝐢𝐝):
https://play.google.com/store/apps/details?id=com.app.seleniuminterviewquestions&referrer=utm_source%3Ddevto%26utm_medium%3Darticle%26utm_campaign%3Dselenium_20260913

🍎 𝐀𝐩𝐩 𝐒𝐭𝐨𝐫𝐞 (𝐢𝐎𝐒):
https://apps.apple.com/app/id6786760948?pt=128640464&ct=devto_selenium_20260913&mt=8

────────────────────────────────────────
Play Store: ────────────────────────────────────────

📲 𝐅𝐑𝐄𝐄 𝐌𝐎𝐁𝐈𝐋𝐄 𝐀𝐏𝐏 — 𝟔𝟎𝟎+ 𝐒𝐃𝐄𝐓 𝐐&𝐀𝐬
Practice real-world interview scenarios offline on the free QA Automation & SDET Prep app:

🤖 𝐆𝐨𝐨𝐠𝐥𝐞 𝐏𝐥𝐚𝐲 (𝐀𝐧𝐝𝐫𝐨𝐢𝐝):
https://play.google.com/store/apps/details?id=com.app.seleniuminterviewquestions&referrer=utm_source%3Ddevto%26utm_medium%3Darticle%26utm_campaign%3Dselenium_20260913

🍎 𝐀𝐩𝐩 𝐒𝐭𝐨𝐫𝐞 (𝐢𝐎𝐒):
https://apps.apple.com/app/id6786760948?pt=128640464&ct=devto_selenium_20260913&mt=8

────────────────────────────────────────
────────────────────────────────────────

Top comments (0)