Performance: Browser testing with Dusk
MEDIUM IMPACT
Browser testing with Dusk affects the development workflow speed and resource usage during automated UI tests, impacting test execution time and system responsiveness.
public function testExample() {
$this->browse(function (Browser $browser) {
$browser->visit('/home')
->waitForText('Welcome', 10) // waits up to 10 seconds but continues as soon as text appears
->assertSee('Welcome');
});
}public function testExample() {
$this->browse(function (Browser $browser) {
$browser->visit('/home')
->pause(5000) // waits fixed 5 seconds
->assertSee('Welcome');
});
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Fixed pause (pause(5000)) | Minimal | Minimal | Minimal but causes idle wait | [X] Bad |
| Dynamic wait (waitForText) | Minimal | Minimal | Minimal and efficient | [OK] Good |