[Bug]: [pest-plugin-browser] assertNoJavaScriptErrors() never fails — errors read back as empty, and not captured at all on app pages
I maintainer di solito rispondono entro 5 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 52/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- php
- Ambito
- testing-qa
Direzione di ricerca
Start with Page::javaScriptErrors(), MakesConsoleAssertions, assertNoJavaScriptErrors(), and the evaluate() path described in the issue. Reproduce the minimal inline-HTML case and then the Vite + Alpine case; done means captured JavaScript errors make the assertion fail and errors on real application pages are captured consistently.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happened?
assertNoJavaScriptErrors() never fails. A page with a guaranteed uncaught TypeError passes it.
Investigating produced two distinct faults, and the second is the one that matters:
| Page under test | window.__pestBrowser.jsErrors.length |
assertNoJavaScriptErrors() |
|---|---|---|
| Minimal inline-HTML route | 1 — error captured correctly | passes ← read bug |
| Real application page (Vite + Alpine) | 0 — error never captured | passes |
1. The read. On a minimal page the init script captures the error correctly, but
assertNoJavaScriptErrors() still passes. Page::javaScriptErrors() does
evaluate('window.__pestBrowser.jsErrors || []') and MakesConsoleAssertions then does
expect($javaScriptErrors)->toBeEmpty() — whatever evaluate() returns for that array,
toBeEmpty() accepts it, even when the array demonstrably has one element.
2. The capture. On a real application page (Vite-loaded modules, Alpine) the same
injected error never reaches window.__pestBrowser.jsErrors at all — the array is empty.
So even a hand-written guard reading that array directly cannot work on the pages one
actually wants to guard.
How to reproduce
use Illuminate\Support\Facades\Route;
beforeEach(function (): void {
Route::get('/__repro', fn () => <<<'HTML'
<!doctype html><html><head><title>repro</title></head>
<body>
<p>hello</p>
<script>window.__definitelyMissing.boom();</script>
</body></html>
HTML);
});
it('the broken script really is in the browser', function (): void {
visit('/__repro')->assertSourceHas('__definitelyMissing'); // passes
});
it('the error IS captured', function (): void {
$page = visit('/__repro');
$page->assertScript('document.readyState', 'complete');
$page->assertScript('window.__pestBrowser.jsErrors.length', 0); // FAILS: "but got 1" — correct
});
it('but the assertion does not fail', function (): void {
visit('/__repro')->assertNoJavaScriptErrors(); // passes — this is the bug
});
Repeat the third test against a page in a real app (Vite + Alpine) and
window.__pestBrowser.jsErrors.length is 0 there — fault 2.
What I ruled out
assertScript()itself is sound. A control asserting1 === 999failed correctly with
"...to evaluate to 999 ... but got 1", so the comparison layer is fine and the readings
above are trustworthy.- Not a timing race on the minimal page. Adding
document.readyState === 'complete',
waitForEvent('load')and extra round trips changed nothing either way. - The script does reach the browser — confirmed with
assertSourceHas()in the same run,
not inferred.
Why it matters
The assertion reads as coverage while asserting nothing. In one codebase here it accounted for
38 assertions across 11 browser test files — all green, none capable of failing.
Package Version
pestphp/pest-plugin-browser v5.0.1
PHP Version
8.4.23
Laravel Version
12.x
Operating System
macOS (also reproduced on self-hosted Linux CI)
Notes
Filed here because issues are disabled on pestphp/pest-plugin-browser. Related but distinct:
#1649 (line numbers missing) presumes errors are detected; #1542 is a different failure mode.
- 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
-
Group 2 - Data Storage | Tripal DBX | Chado Group 5 - Search | ElasticSearch | Views Priority - Medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
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