All jobs / Frontend / web developer / Testing
Frontend / web developer interview question · 3–5 years
A Playwright or Cypress suite fails about one run in five on CI, in different places. The tests are full of fixed two-second waits and long CSS selectors.
How do you make it trustworthy?
The strongest answer
Remove fixed sleeps in favour of the tool’s auto-waiting assertions, locate by role or test id, give each test its own seeded data, and use traces from failed runs to find the rest
Why it works
Exactly — flakiness has causes: timing guesses, brittle selectors, shared data. Web-first assertions wait for the condition, not the clock.
What a good answer covers
- Wait for conditions, not for time.
- Replace sleeps with auto-waiting assertions.
- Stable locators; isolated test data.
- Read traces; fix root causes.
Answers that fall short
- Close, but not the strongest: Turn on automatic retries so a failing test is run again up to three times
Retries keep the pipeline moving but hide real races; use them with a flake report, not instead of a fix. - Weak: Increase every wait from two seconds to ten so slow CI machines have enough time
Longer sleeps make the suite slower and still lose on the day CI is slower than ten seconds. - Red flag: Delete the tests that fail most often so the suite stops blocking merges
The flakiest tests often sit on the most complex flows — the ones you most need covered.
Who gets asked this
More Testing questions
- After a bad release, management asks you to enforce 90% code coverage on the frontend repository as a merge…
- How do you catch layout breakage before you translate into German and Hebrew?
- What is the difference between a unit test, a component test and an end-to-end test on the frontend, and…
- How do you assert a login button in React Testing Library?
- How do you test a search box that debounces input by 300 ms, in Jest or Vitest, without slowing the suite…
- A test passes when run alone and fails when the whole file runs, and the failing test changes when you…