[pest-plugin-browser] Give page navigation its own timeout, separate from the assertion timeout
I maintainer di solito rispondono entro 5 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 57/100
Direzione di ricerca
The issue names PendingAwaitablePage::buildAwaitablePage() and InteractsWithToolbar as the navigation entry points. Read how timeout() is applied to goto and the toolbar navigation methods, then check the related tests for navigation timeouts. Done means a separate navigation timeout applies to all listed navigation methods, defaults to the existing timeout, and the failure message identifies a timed out navigation.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Filing here because pestphp/pest-plugin-browser has issues disabled.
Problem
pest()->browser()->timeout() sets one timeout for both assertions and page navigation. visit() is lazy: the first call chained on it opens a new context and page and calls goto with waitUntil: 'load', all within that timeout (PendingAwaitablePage::buildAwaitablePage()). navigate(), refresh(), back() and forward() use it as well.
So when a page's load event is slow, its first assertion fails with a bare timeout, even though the assertion never ran and the text it looks for was in the HTML at once:
use Illuminate\Support\Facades\Route;
it('sees the text', function (): void {
Route::get('/repro/slow.js', function () {
usleep(6_000_000);
return response('', 200, ['Content-Type' => 'text/javascript']);
});
Route::get('/repro/page', fn () => '<html><body><p>Hello</p><script src="/repro/slow.js"></script></body></html>');
visit('/repro/page')->assertSee('Hello');
});
With the default timeout of 5000 ms, this fails on the ->assertSee('Hello') line with nothing but:
Timeout 5000ms exceeded.
There is no screenshot either, because the timeout is hit before the page is handed to the test.
In a real app the load event is slow more often than you would expect. It waits for every script, stylesheet, font and image, and each test starts with an empty browser cache, while every parallel worker loads its first page at the same moment. Our app loads about 60 files from public CDNs. With 16 parallel workers, the first call after visit() regularly took more than 5 seconds, and one run failed 11 of 69 tests with Timeout 5000ms exceeded. on that call.
Raising timeout() avoids that, but makes every genuinely failing assertion take that much longer to report.
Workaround
visit() and navigate() pass their options on to goto, so this works:
visit('/repro/page', ['timeout' => 30_000])->assertSee('Hello');
But it has to be repeated in every call, and refresh(), back() and forward() take no options.
Proposal
A separate navigation timeout, like Playwright's setDefaultNavigationTimeout() next to setDefaultTimeout():
pest()->browser()
->timeout(5_000) // assertions and other actions
->navigationTimeout(30_000); // visit(), navigate(), refresh(), back(), forward()
It would apply to goto in PendingAwaitablePage::buildAwaitablePage() and to the navigation methods in InteractsWithToolbar. Defaulting it to timeout() keeps the current behaviour for everyone who does not set it.
Related, and smaller: name the step that timed out, e.g. Timeout 5000ms exceeded while loading [http://127.0.0.1:61284/repro/page]., so the failure does not read as a failed assertion.
The browser launch already has its own timeout: it happens during initialize, which uses LAUNCH_TIMEOUT since pestphp/pest-plugin-browser#275.
Happy to open a PR if this direction works for you.
Versions: pest-plugin-browser 5.2.0 (the code is the same on 5.x today), Playwright 1.64.1, PHP 8.5, macOS and Ubuntu (GitHub Actions).
- Lingua principale
- PHP
- Stelle
- 11.8k
- Fork
- 559
- Merge medio
- 5g 23h
- PR unite (30g)
- 24
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pestphp/pest
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 5 giorni
-
[Bug]: --mutate hides unreadable files, so mutants behind a failed read can never be killedForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 5 giorni
-
[Bug]: [mutate] Windows: @pest-mutate-ignore comments land on line 1 in files with LF line endingsForse già presa @webdevsamran l’ha presa 57 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 5 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 5 giorni
-
[pest-plugin-browser] Page::waitForLoadState() never sends its message — waitForEvent() is a silent no-opForse già presa @asllanmaciel l’ha presa 70 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
pestphp/pest#1892 · 2 commenti ·
I maintainer di solito rispondono entro 5 giorni
Tutte le issue di pestphp/pest
Issue simili
-
nginx update required due to NGINX2RootForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
mailcow/mailcow-dockerized#7668 · 5 commenti · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
lara-zeus/spatie-translatable#80 ·
I maintainer di solito rispondono entro 1 giorno
-
small
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
uiowa/uiowa#10296 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
asyncapi/modelina#2709 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
My-Little-Forum/mylittleforum#937 ·