QA-PW-002 — Unawaited Playwright assertion
Generated from the rule registry. Get the same detail from the CLI with
mjolnir explain QA-PW-002.
| Field | Value |
|---|---|
| Severity | error |
| Confidence | high |
| Tier | extended |
| Measured FP rate | 0% (n=20) |
| Evidence level | E2 |
| QA impact | False-green risk (FALSE-GREEN) |
| False-positive risk (author estimate) | low |
| Autofix available | no |
| Languages | typescript, javascript |
| Frameworks | playwright |
| Detection strategy | AST (ts-morph call-graph check) |
| Introduced in | v0.1.0 |
Why this fails in production
Playwright's assertions (expect(locator)...) and most locator actions return Promises. A call like expect(locator).toBeVisible() without await in front of it starts the assertion, does not wait for its result, and the test function moves on immediately — exactly the same unawaited-promise mechanism as QA-TQUAL-009, but specific enough to Playwright's API shape (and common enough in Playwright suites) to warrant its own detector and fixture pair.
What gets flagged (real detector output)
Playwright locator assertion is not awaited.Example from this rule's own must-fire fixture: tests/fixtures/QA-PW-002/must-fire/unawaited.spec.ts
The fix
Add await: await expect(locator).toBeVisible().
Confirmed NOT to fire on the corresponding clean pattern
Verified against tests/fixtures/QA-PW-002/must-not-fire/clean.spec.ts — a legitimate, similar-looking pattern this rule correctly leaves alone.
Corpus-measured false-positive risk
Real occurrence counts from npm run corpus:audit against actively-maintained OSS repos — reproduce yourself, don't just trust this table (see the false-positive audit):
| Repo | Occurrences |
|---|---|
| dubinc-dub | 12 |
| grafana-grafana | 6 |
| sveltejs-kit | 17 |