Enforce Pragmatic Test Coverage
Flags logic changes without success and failure path tests, snapshot-only or truthy-only assertions, skipped tests, and mocks that hide the behavior.
What it flags
import { describe, expect, it, vi } from 'vitest';
import { applyDiscount } from './apply-discount';
// Mocks the pricing logic this PR changed, so nothing real is tested
vi.mock('./pricing', () => ({ discountedTotal: vi.fn(() => 80) }));
describe('applyDiscount', () => {
it('works', () => {
const result = applyDiscount({ subtotal: 100, code: 'SAVE20' });
expect(result).toBeDefined();
});
it.skip('rejects expired codes', () => {});
});import { describe, expect, it } from 'vitest';
import { applyDiscount } from './apply-discount';
describe('applyDiscount', () => {
it('takes 20% off with a valid code', () => {
expect(applyDiscount({ subtotal: 100, code: 'SAVE20' })).toEqual({
total: 80,
discount: 20,
});
});
it('rejects an expired code', () => {
const now = new Date('2027-01-01T00:00:00Z');
expect(() => applyDiscount({ subtotal: 100, code: 'SAVE20', now })).toThrow(
'Discount code has expired',
);
});
it('never takes the total below zero', () => {
expect(applyDiscount({ subtotal: 10, code: 'FLAT50' }).total).toBe(0);
});
});Why it matters
Coverage numbers reward tests that execute code whether or not they check anything. A test that mocks the logic under test, or asserts only that a result is defined, keeps CI green while the behavior it claims to cover breaks. Demanding tests for every export or config change creates noise that reviewers learn to ignore, so the useful question is narrower: would any test fail if the behavior this PR changes broke?
Agent instructions
cubic checks every pull request against these instructions. Paste them into AGENTS.md or Cursor rules and your AI coding tool follows them while it writes code.
AGENTS.md
Add this section to AGENTS.md at the repository root. Codex, Cursor, and other AI coding tools read it.
## Enforce Pragmatic Test Coverage Be reasonable when evaluating tests. Flag changes when important behavior is untested, but do not require tests for every export, type, config, metadata file, or mechanical change. Flag PRs that: - Change core business logic without covering the main success and failure paths. - Add UI behavior without testing the user-visible interaction or state change. - Add tests that only assert rendering, existence, snapshots, or that a function returns any value. - Skip, mute, or weaken existing tests without a clear reason. - Mock so much of the system that the test no longer validates the behavior the PR claims to change.
Checks every changed file.
Included in the React, Next.js, TypeScript, Node.js, Python, Django, Ruby on Rails, Go, Spring Boot, and PostgreSQL code review standards.
Run this agent on every pull request
cubic reviews every pull request against the agents you turn on and comments on the lines that break them.