Mock
This is how the comment reads inline, under the flagged line.
Why it matters
Every mock is a place where the test checks your assumption about the other code instead of the code itself. Heavy mocking is how suites pass while production breaks.
What to do
Use the real implementation or an in-memory fake, and prefer one end-to-end check over many mocked units.
Examples
vi.mock("./db");const db = createTestDb();
What it catches
It reads a pattern on each line, aware of strings and comments. Languages: TypeScript and JavaScript, Python. Scope: Test files only. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
vi.mock("./db");tests/test_a.py
def test_a(monkeypatch):
monkeypatch.setattr(x, 'y', 1)
assert x
Left alone
const db = createTestDb();
Research
Mocking the code under test, or mocking so much that the test checks only mocks. The test proves the mock setup, not the code.
- OWASP: Secure coding with AI
- vibecop detectors
- owner's code bar
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"mock-heavy"
],
"severity": {
"mock-heavy": "medium"
}
}
}
vi.mockreplaces real code in this test. That seam is no longer tested.