Skip to main content

SKY-A110 · AI-code defects

Test deleted

High

A test that existed at the base commit is gone after the change, and no test with the same body exists anywhere else. SKY-A110 also reports a test left with no assertion at all, a test overwritten in place by one that tests something else, and a parametrized test that lost cases.

Languages
Python tests (pytest, unittest), JavaScript/TypeScript tests (Jest, Vitest, Mocha, node:test, Playwright)
Turned on by
skylos done (compares uncommitted changes with HEAD) or skylos done --base origin/main for a pull request; agent hooks run it when the agent stops
Quality gate
not checked (full and diff scans). Only skylos done reports it, in its test_tampering check, which blocks by default: one deleted test fails the verdict. A test deleted together with the code it tested, a rewritten test, or one with fewer assertions is listed as advice and does not block. skylos cicd risk-review counts a blocking finding as "tests weakened", which needs a human approval.
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

When a coding agent cannot make a test pass, deleting the test is the fastest way to a green run. The behaviour that test protected then has no check at all, and a deleted block in a long diff is easy to miss in review.

What Skylos flags

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

billing/discounts.py · Python · changed
"""Discount rules for the checkout."""  def apply_discount(price, percent):Removed:     if not 0 <= percent <= 100:Removed:         raise ValueError("percent must be between 0 and 100")Added:     percent = min(max(percent, 0), 100)    return round(price * (100 - percent) / 100, 2)
tests/test_discounts.py · Python · changed
import pytest from billing.discounts import apply_discount  def test_applies_percentage():    assert apply_discount(200, 25) == 150Removed:  Removed:  Removed: def test_rejects_percent_over_100():Removed:     with pytest.raises(ValueError):Removed:         apply_discount(200, 120)

What Skylos leaves alone

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

tests/test_discounts.py · Python · changed
Removed: import pytestRemoved:  from billing.discounts import apply_discount  def test_applies_percentage():    assert apply_discount(200, 25) == 150Removed:  Removed:  Removed: def test_rejects_percent_over_100():Removed:     with pytest.raises(ValueError):Removed:         apply_discount(200, 120)
tests/test_discount_limits.py · Python · new file
import pytest from billing.discounts import apply_discount  def test_rejects_percent_over_100():    with pytest.raises(ValueError):        apply_discount(200, 120)
1 committed file the change leaves alone

billing/discounts.py: same as in the flagged example.

Why Skylos leaves it alone

The test left test_discounts.py but still exists, with the same body, in a new file. Skylos matches tests by body, so a moved or renamed test is not a deletion.

More languages

JavaScript

Flagged

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

src/cart.test.js · JavaScript · changed
import { cartTotal } from "./cart"; test("adds up price times quantity", () => {  expect(cartTotal([{ price: 5, qty: 2 }])).toBe(10);});Removed:  Removed: test("refuses a negative quantity", () => {Removed:   expect(() => cartTotal([{ price: 5, qty: -1 }])).toThrow();Removed: });
1 committed file the change leaves alone
src/cart.js · JavaScript
export function cartTotal(items) {  if (items.some((item) => item.qty < 0)) {    throw new Error("negative quantity");  }  return items.reduce((sum, item) => sum + item.price * item.qty, 0);}

Not flagged

A change: the first version of these files is committed, then the edit below is made without committing, and Skylos reviews it as a diff scan (--diff).

src/cart.test.js · JavaScript · changed
import { cartTotal } from "./cart"; test("adds up price times quantity", () => {  expect(cartTotal([{ price: 5, qty: 2 }])).toBe(10);}); Removed: test("refuses a negative quantity", () => {Added: test("rejects a negative quantity", () => {  expect(() => cartTotal([{ price: 5, qty: -1 }])).toThrow();});
1 committed file the change leaves alone

src/cart.js: same as in the flagged example.

Why Skylos leaves it alone

Only the title changed. The body is the same, so Skylos pairs the two tests as a rename and reports nothing.

How Skylos decides

  1. Runs in skylos done, which compares the working tree (or a pull request's head) with a base commit: HEAD by default, the merge base with --base. Its settings come from the base commit, never from the change.
  2. Builds a static inventory of every test at the base and at head without importing anything: pytest functions and Test* methods in test_*.py and *_test.py files, unittest.TestCase methods in any Python file, and it, test, specify calls (inside describe blocks) in *.test.*, *.spec.* and __tests__ JavaScript and TypeScript files. Each test records a hash of its body and how many assertions it makes.
  3. Pairs each base test with a head test of the same file, class and name. A base test with no partner is then matched to a new test with the same body (a move or rename, not reported), to a new test with a similar title and body, to the same name under a renamed class or describe, or to a new test written where it stood. The later pairings are rewrites.
  4. A base test still unpaired is a deletion. It is advice instead of a blocking finding when the test used a function, class or module the change removed, or asserted text the change deleted from the code, so a feature removed with its tests does not block.
  5. Also reports, as blocking: a paired test left with no countable assertion, a test overwritten in place by one about a different subject, and a parametrize or .each table with fewer literal cases. Fewer assertions, a new early return and other rewrites are advice.
  6. A deleted test is reported at its line in the base version of the file.

How to fix it

Put the test back and change the code until it passes. If the behaviour really changed on purpose (here, clamping instead of refusing), replace the test with one that checks the new behaviour, in the same change.

Fix · Python
def test_clamps_percent_over_100():    assert apply_discount(200, 120) == 0

When it can be wrong

  • A test deleted on purpose, such as a duplicate or a test for behaviour the product no longer has, is reported unless the change also removes the code or text the test used. Say why in the pull request; a reviewer can accept it.
  • A JavaScript test whose title is a template literal with ${...}, a variable or another expression is not inventoried, so its deletion is not seen.
  • A test moved and heavily edited in the same change can look like a deletion plus a new test when its title and body both differ too much.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • skylos done findings ignore # skylos: ignore[...] comments and the [tool.skylos] ignore list. To stop this check from blocking, commit a lower mode to the base branch first (the change under review cannot loosen its own check):

    TOML
    [tool.skylos.done.checks]test_tampering = "advise"

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.