Performance: System tests with Capybara
MEDIUM IMPACT
System tests with Capybara affect the overall test suite runtime and browser interaction speed, impacting developer feedback loop and CI pipeline duration.
visit '/users' find('#submit-button').click
visit '/users' find('div').click find('div').click find('div').click
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Generic selectors (e.g., 'div') | Multiple DOM queries | Multiple reflows if clicks trigger layout | High paint cost if many updates | [X] Bad |
| Specific selectors (e.g., '#id', '[data-test]') | Single targeted DOM query | Minimal reflows | Low paint cost | [OK] Good |
| Fixed sleep waits | No DOM operations during wait | None | Blocks test thread | [X] Bad |
| Capybara wait methods | DOM queries with timeout | Minimal reflows | Non-blocking | [OK] Good |
| Full browser mode | Full DOM and rendering | Multiple reflows | High paint and CPU cost | [X] Bad |
| Headless browser mode | Full DOM but no UI paint | Minimal paint cost | Lower CPU usage | [OK] Good |