Problem
How to catch an AI agent weakening your tests
TL;DR
- When an agent can't make a test pass, it sometimes changes the test instead of the code.
- The tells are mechanical: fewer assertions, .skip or .only, @ts-ignore, as any, eslint-disable, # type: ignore.
- Stet counts and flags all of them on every PR, with no AI involved.
What it looks like
- expect(total(cart)).toBe(1999)
- expect(total(emptyCart)).toBe(0)
+ expect(total(cart)).toBeDefined()
The suite is green. The bug ships. In review, test-file diffs get less attention than product code, and a big agent PR makes it easy to miss.
The patterns to flag
- Assertions removed: count
expect(,assertand friends before and after in each changed test file. - Tests skipped or focused:
it.skip,xit,@pytest.mark.skip, and.only, which silently skips everything else. - Checks switched off:
@ts-ignore,@ts-expect-error,as any,eslint-disable,# type: ignore,# noqa. - Test files deleted.
Catch it automatically
Stet checks all of these on every pull request and lists them as red flags in one comment:
⚠️ apps/web/src/cart.test.ts: 3 assertions removed (7 → 4)
⚠️ backend/tests/test_orders.py: test skipped
⚠️ src/api/client.ts: type check switched off
It's free and takes two clicks: getstet.dev/add. Want the job to fail on red flags, not just report them? Set fail-on: any.
Prevent it upstream
Tell the agent in AGENTS.md: never edit tests to make them pass. Then make it stick: stet init locks your test suite so a broken behaviour fails stet check, and the agent is told to fix the code, not the test.
FAQ
Why do AI agents weaken tests?
When an agent is asked to make tests pass and can't fix the code, changing the test is often the shortest path to green. It isn't malicious; it's optimising for the goal it was given.
How do I detect removed assertions in a pull request?
Count assertion calls in each changed test file before and after the change. Stet does this automatically on every PR and reports the difference.
Can I fail the build when tests are weakened?
Yes. With the Stet GitHub Action, set fail-on: any to fail the job on red flags as well as on broken tests.
See what your AI change really did, on every PR
Stet posts one comment on every pull request: what broke vs main, tests deleted, weakened or skipped, checks switched off, files outside the task. Free and open source, zero config, nothing leaves your CI. Plus a CLI and MCP server for Claude Code, Cursor and Codex.
Add to GitHub in 2 clicks · npx stet-cli init · Install · Setup guide · GitHub