Testing & QA Bug Hunt Hard +35 XP
Integration Test Flakiness
Tests randomly fail due to timing issues.
Testing & QAFind the bug
1
test('data loads', () => {2
clickButton();3
expect(screen.getByText('Loaded')).toBeInTheDocument();4
}); The bug is on line 3
Select the correct fix
Show answer and explanation
Answer: Use await findByText() which waits for element
getByText is synchronous and fails if element isn't there yet. findByText returns a promise that retries until the element appears.
Hint: findBy* queries are async and retry automatically.
What this challenge tests
Bug Hunt in Testing & QA: testing-library, async.