Q14 of 21 · AI for testing
How do you use AI during code review of test code?
Short answer
Short answer: Use AI to flag common anti-patterns — hard waits, incomplete assertions, shared mutable state between tests, missing negative cases — and suggest improvements. Treat it as a first-pass reviewer that frees humans for judgment calls AI cannot make.
Detail
In practice: paste a test file and ask the model to review it for hard waits (cy.wait(2000)), assertions that only check the response status but not the body, tests that depend on execution order, missing negative cases, and locators that are likely brittle.
AI is good at syntactic and structural anti-pattern detection — the same class of issues a linter would catch if the rules existed. It is poor at judging whether the test covers the right behaviour, because that requires domain understanding of the application.
For teams: integrate AI review as a PR template step ("run this diff through this prompt before requesting human review"). This normalises AI review without making it a replacement for engineering judgment about whether the test is actually testing the right thing. See AI PR review and test gen for prompt templates.