Skip to content

QA-PW-002 — Unawaited Playwright assertion ​

← Back to the rule catalog

Generated from the rule registry. Get the same detail from the CLI with mjolnir explain QA-PW-002.

FieldValue
Severityerror
Confidencehigh
Tierextended
Measured FP rate0% (n=20)
Evidence levelE2
QA impactFalse-green risk (FALSE-GREEN)
False-positive risk (author estimate)low
Autofix availableno
Languagestypescript, javascript
Frameworksplaywright
Detection strategyAST (ts-morph call-graph check)
Introduced inv0.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):

RepoOccurrences
dubinc-dub12
grafana-grafana6
sveltejs-kit17

Released under the MIT License.