GitHub user dosubot[bot] added a comment to the discussion: Flaky Frontend Tests?
<!-- Greeting --> Hi @ZeroWiggliness! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the superset team. <!-- Answer --> Yes, frontend test flakiness (especially timeouts) is a well-documented problem in Superset. The team has been actively fixing these across multiple PRs. Here's what's going on and what you can try: **Root cause for most timeouts:** The most common culprit is **unmocked API endpoints** — when a component makes an API call on mount but the test doesn't mock that endpoint, Jest hangs waiting for a response until it hits the 20-second timeout [[1]](https://github.com/apache/superset/pull/35810). The global timeout is set to 20000ms in `jest.config.js` [[2]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/jest.config.js#L79). **Specifically for `EmbeddedModal.test.tsx`:** There's a race condition in the test setup where `resetMockApi()` is called *after* `render()`, but the component's `useEffect` fires during render — meaning API calls can execute before mocks are configured [[3]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/dashboard/components/EmbeddedModal/EmbeddedModal.test.tsx#L59-L62). Moving `resetMockApi()` before `render()` in the `setup` function should help. **Why sharding helps:** The CI uses [8-way Jest sharding](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/.github/workflows/superset-frontend.yml#L66-L91) to parallelize tests, which reduces memory pressure and timer pollution between tests — both known causes of intermittent failures. **What the team has been fixing recently:** - [PR #36037](https://github.com/apache/superset/pull/36037): Fixed React Testing Library anti-patterns (redundant double-awaits, `userEvent` inside `waitFor` callbacks) - [PR #35993](https://github.com/apache/superset/pull/35993): Fixed 30+ unawaited `userEvent` calls and missing API mocks - [PR #38430](https://github.com/apache/superset/pull/38430): Fixed OOM crashes in tests by mocking heavy child components (reduced heap from 615MB to 287MB) **Quick things you can try:** 1. **Use sharding** like CI does: `npm run test -- --shard=1/8`, `--shard=2/8`, etc. 2. **Increase `--maxWorkers`** or decrease it (e.g., `--maxWorkers=2`) to reduce memory contention 3. For specific failing tests, increase the timeout as a workaround: `test('name', async () => { ... }, 60000)` 4. Ensure proper cleanup in `afterEach` — call `jest.runOnlyPendingTimers()` *before* `jest.useRealTimers()` to avoid timer pollution [[1]](https://github.com/apache/superset/pull/35810) Modal components in particular are prone to this kind of flakiness — [FiltersConfigModal.test.tsx was actually skipped after 11 fix attempts](https://github.com/apache/superset/issues/36964) due to complex Redux + API mock coordination issues. Since you're on the 6.0 branch, you may not have all the recent flakiness fixes. It might be worth cherry-picking or checking if the fixes from the PRs above apply to your branch. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=brand-link).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-great_response#message_id=643d5180-5efe-4583-a6d5-c7fd102c9dca&feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-irrelevant_answer#message_id=643d5180-5efe-4583-a6d5-c7fd102c9dca&feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-incorrect_sources#message_id=643d5180-5efe-4583-a6d5-c7fd102c9dca&feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-too_verbose#message_id=643d5180-5efe-4583-a6d5-c7fd102c9dca&feedback_type=too_verbose) | [Hallucination](https://app .dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-hallucination#message_id=643d5180-5efe-4583-a6d5-c7fd102c9dca&feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-bug_report#message_id=643d5180-5efe-4583-a6d5-c7fd102c9dca&feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-other#message_id=643d5180-5efe-4583-a6d5-c7fd102c9dca&feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=chat-badge) [](https://cursor.com/link/prompt?text=Yes%2C%20frontend%20test%20flakiness%20%28especially%20timeouts%29%20is%20a%20well-documented%20problem%20in%20Superset.%20The%20team%20has%20been%20actively%20fixing%20these%20across%20multiple%20PRs.%20Here%27s%20what%27s%20going%20on%20and%20what%20you%20can%20try%3A%0A%0A%2A%2ARoot%20cause%20for%20most%20timeouts%3A%2A%2A%20The%20most%20common%20culprit%20is%20%2A%2Aunmocked%20API%20endpoints%2A%2A%20%E2%80%94%20when%20a%20component%20makes%20an%20API%20call%20on%20mount%20but%20the%20test%20doesn%27t%20mock%20that%20endpoint%2C%20Jest%20hangs%20waiting%20for%20a%20response%20until%20it%20hits%20the%2020-second%20timeout%20%5B%5B1%5D%5D%28https%3A//github.com/apache/supers et/pull/35810%29.%20The%20global%20timeout%20is%20set%20to%2020000ms%20in%20%60jest.config.js%60%20%5B%5B2%5D%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/jest.config.js%23L79%29.%0A%0A%2A%2ASpecifically%20for%20%60EmbeddedModal.test.tsx%60%3A%2A%2A%20There%27s%20a%20race%20condition%20in%20the%20test%20setup%20where%20%60resetMockApi%28%29%60%20is%20called%20%2Aafter%2A%20%60render%28%29%60%2C%20but%20the%20component%27s%20%60useEffect%60%20fires%20during%20render%20%E2%80%94%20meaning%20API%20calls%20can%20execute%20before%20mocks%20are%20configured%20%5B%5B3%5D%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/dashboard/components/EmbeddedModal/EmbeddedModal.test.tsx%23L59-L62%29.%20Moving%20%60resetMockApi%28%29%60%20before%20%60render%28%29%60%20in%20the%20%60setup%60%20function%20should%20help.%0A%0A%2A%2AWhy%20sharding%20helps%3A%2A%2A%20The%20CI%20uses%20% 5B8-way%20Jest%20sharding%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/.github/workflows/superset-frontend.yml%23L66-L91%29%20to%20parallelize%20tests%2C%20which%20reduces%20memory%20pressure%20and%20timer%20pollution%20between%20tests%20%E2%80%94%20both%20known%20causes%20of%20intermittent%20failures.%0A%0A%2A%2AWhat%20the%20team%20has%20been%20fixing%20recently%3A%2A%2A%0A%0A-%20%5BPR%20%2336037%5D%28https%3A//github.com/apache/superset/pull/36037%29%3A%20Fixed%20React%20Testing%20Library%20anti-patterns%20%28redundant%20double-awaits%2C%20%60userEvent%60%20inside%20%60waitFor%60%20callbacks%29%0A-%20%5BPR%20%2335993%5D%28https%3A//github.com/apache/superset/pull/35993%29%3A%20Fixed%2030%2B%20unawaited%20%60userEvent%60%20calls%20and%20missing%20API%20mocks%0A-%20%5BPR%20%2338430%5D%28https%3A//github.com/apache/superset/pull/38430%29%3A%20Fixed%20OOM%20crashes%20in%20tests%20by%20mocking%20heavy%20child%20components%20%28reduced%20heap%2 0from%20615MB%20to%20287MB%29%0A%0A%2A%2AQuick%20things%20you%20can%20try%3A%2A%2A%0A%0A1.%20%2A%2AUse%20sharding%2A%2A%20like%20CI%20does%3A%20%60npm%20run%20test%20--%20--shard%3D1/8%60%2C%20%60--shard%3D2/8%60%2C%20etc.%0A2.%20%2A%2AIncrease%20%60--maxWorkers%60%2A%2A%20or%20decrease%20it%20%28e.g.%2C%20%60--maxWorkers%3D2%60%29%20to%20reduce%20memory%20contention%0A3.%20For%20specific%20failing%20tests%2C%20increase%20the%20timeout%20as%20a%20workaround%3A%20%60test%28%27name%27%2C%20async%20%28%29%20%3D%3E%20%7B%20...%20%7D%2C%2060000%29%60%0A4.%20Ensure%20proper%20cleanup%20in%20%60afterEach%60%20%E2%80%94%20call%20%60jest.runOnlyPendingTimers%28%29%60%20%2Abefore%2A%20%60jest.useRealTimers%28%29%60%20to%20avoid%20timer%20pollution%20%5B%5B1%5D%5D%28https%3A//github.com/apache/superset/pull/35810%29%0A%0AModal%20components%20in%20particular%20are%20prone%20to%20this%20kind%20of%20flakiness%20%E2%80%94%20%5BFiltersConfigModal.test.tsx%20was%20actually%20skipped%20after%2011%20f ix%20attempts%5D%28https%3A//github.com/apache/superset/issues/36964%29%20due%20to%20complex%20Redux%20%2B%20API%20mock%20coordination%20issues.%0A%0ASince%20you%27re%20on%20the%206.0%20branch%2C%20you%20may%20not%20have%20all%20the%20recent%20flakiness%20fixes.%20It%20might%20be%20worth%20cherry-picking%20or%20checking%20if%20the%20fixes%20from%20the%20PRs%20above%20apply%20to%20your%20branch.) [](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/39010) GitHub link: https://github.com/apache/superset/discussions/39010#discussioncomment-16410168 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
