DEV Community

Shamaz Khan
Shamaz Khan

Posted on

Your PR is green. Your test is gone.

The build is green. The PR looks clean. The reviewer approves it.

And a test that used to protect you no longer checks anything.

That's the quiet failure mode of AI coding agents. Ask one to make the build pass and it will, usually by fixing the code, but sometimes by changing the check instead: an assertion removed, a test skipped, a type check switched off. Nothing fails, so nothing tells you. You find out in production, weeks later, when the bug the test was guarding against ships.

None of this is malicious. The agent was asked for a green build, and it delivered one. These are the five patterns worth looking for in every AI-written pull request.

1. The assertion that disappeared

Before:

test('applies the discount', () => {
  const total = checkout(cart, 'SAVE10');
  expect(total.discount).toBe(10);
  expect(total.amount).toBe(90);
});
Enter fullscreen mode Exit fullscreen mode

After the agent "fixed" it:

test('applies the discount', () => {
  const total = checkout(cart, 'SAVE10');
  expect(total.discount).toBe(10);
});
Enter fullscreen mode Exit fullscreen mode

The test still exists, still passes and still has the same name. It just doesn't check the amount any more, which was the part that was broken.

What to look for: count the assertions in each changed test file, before and after. Fewer assertions in a PR that wasn't about tests is a red flag.

2. The skipped (or focused) test

it.skip('rejects an expired token', async () => {
Enter fullscreen mode Exit fullscreen mode

or the opposite, which is worse:

it.only('returns the user profile', async () => {
Enter fullscreen mode Exit fullscreen mode

.skip silences one test. .only silences every other test in the file, and the run still reports green. In Python it's @pytest.mark.skip; in Go, t.Skip().

What to look for: any new skip, only, xit, xdescribe or @pytest.mark.skip in the diff.

3. The type check that got switched off

// @ts-ignore
const user: User = await fetchUser(id);
Enter fullscreen mode Exit fullscreen mode
const total = (order as any).items.reduce(sum, 0);
Enter fullscreen mode Exit fullscreen mode

The type error was telling you something real: fetchUser can return null. Now it can't tell you any more, and you find out at runtime.

What to look for: new @ts-ignore, @ts-expect-error, as any, eslint-disable, # type: ignore or # noqa lines.

4. The expected value that moved to match the bug

- expect(formatPrice(1999)).toBe('$19.99');
+ expect(formatPrice(1999)).toBe('$1999.00');
Enter fullscreen mode Exit fullscreen mode

This one is the hardest to spot, because the diff looks like a reasonable update. The agent changed the expectation to match what the code now returns, so the test now locks in the bug.

Snapshot tests make it even easier: run jest -u, every snapshot is "updated", and the diff is 400 lines nobody reads.

What to look for: changed expected values or snapshots in a PR that wasn't supposed to change behaviour.

5. The test file that was deleted

The bluntest version: a test file that kept failing is no longer in the repo. It shows up as one line in the file list, between the changes you actually asked for.

What to look for: deleted files under test/, tests/, __tests__/ or anything matching *.test.* / *_test.*.

Why review alone doesn't catch this

Each of these is small, sits next to real changes, and looks plausible. An AI reviewer reading the same diff can miss it for the same reason a tired human does. And none of them makes the build fail, which is the whole point.

What works is checking mechanically, on every PR, the same way every time:

  1. Run the tests on the PR and on main. Anything that passes on main and fails on the PR was broken by this change. Anything that fails on both was already broken, so don't blame the PR for it.
  2. Read the diff for the five patterns above: assertions removed, tests skipped or focused, checks switched off, and test files deleted. Treat expected values and snapshots as "explain this change".
  3. Put the result where the reviewer already looks: on the PR itself.

Automating it

Doing this by hand on every PR doesn't last, so I built a small open-source tool for it, Stet. It's free (MIT), and there's no AI in the check, so the same diff always gets the same answer.

On every pull request it posts one comment:

  • what the PR broke compared with main, and what was already failing on main
  • red flags from the diff: assertions removed (with the before/after count), tests skipped or .only, @ts-ignore / as any / eslint-disable added, test files deleted, and lockfile, CI or env changes
  • each red flag marked on its exact line in Files changed

It doesn't catch pattern 4 yet (an expected value or snapshot quietly changed to match a bug). That one needs a human eye for now, and it's next on my list.

It works with zero config. Add it to a repo in two clicks at getstet.dev/add, or add the workflow yourself:

name: Stet
on:
  pull_request:
    types: [opened, synchronize, reopened]
permissions:
  contents: read
  pull-requests: write
  checks: write
jobs:
  stet:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }
      - uses: stet-dev/stet-action@v2
Enter fullscreen mode Exit fullscreen mode

Or run it locally before you push:

npx stet-cli report --base main
Enter fullscreen mode Exit fullscreen mode

If you use Claude Code or Antigravity, there's also a plugin: ask your agent "Check my changes with Stet" and it runs the check before it tells you it's done.


Which of these have you caught in your own repos? And is there a sixth pattern I should be checking for? I'm adding new checks based on what people actually run into.

Top comments (3)

Collapse
 
remycalder profile image
Remy Calder •

a sixth one I'd check is the test config instead of the tests. stuff like a new testPathIgnorePatterns entry in the jest config, addopts = -k "not slow" or a --deselect in pytest.ini, a conftest.py hook that skips by marker, continue-on-error: true on the CI test step, or || true added to the test script in package.json. none of those touch a test file, so a check that only looks under tests/ won't see them. a lowered coverage threshold is kind of the same thing.

the other one is mocking the thing under test. if a new jest.mock('./checkout') shows up in checkout.test.ts, every assertion still runs and passes but nothing real is being checked anymore.

for pattern 4, a cheap heuristic might be to only flag a changed expected value when the same PR also touched the source file that test imports, and the PR wasn't described as a behaviour change. that combo is the suspicious one, an updated expectation on its own usually isn't.

disclosure: I'm building something in the same area (checking whether agent PRs actually make the product better), and this comment was drafted with an AI agent.

Collapse
 
shamazkhan profile image
Shamaz Khan •

Really appreciate this, Remy. The test configuration bypass is a particularly good catch. A green PR means very little if the agent can quietly change what gets tested. Mocking the actual implementation is another interesting blind spot worth exploring in Stet.

Curious about what you're building too. Are you approaching this from a product quality perspective or enforcing engineering boundaries before changes are accepted? Would love to compare notes. Clearly, we're both scratching a similar itch.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.