existing-tests
How these rules apply to a repo's existing tests.
The rule
Agents read this text as written when they write and review code.
These rules describe the tests you write, not a mandate to rewrite the ones already there. When a repo's tests use an older style, such as beforeEach with a shared let, or nested describe blocks:
- When you extend an existing test file, match its style, and never mix a second style into it. A blocking rule still holds in every test you add or change.
- When you create a test file, follow these rules, even when the test you mirror uses the older style. Mirror its coverage, not its structure.
- Never rewrite passing older tests to these rules during a feature task. That is cleanup with its own review.
Following this order is normal work, with nothing to report. Report it only when this rule failed you, because the conflict was not about style, or it was unclear which case applied.
Examples
The agent flags code like the incorrect example and accepts code like the correct one. Each example is a small repo, because this rule looks across files. It opens on the file that matters; the other files are the repo around it.
Incorrect
import { expect, describe, test, beforeEach } from '@jest/globals';import { getLabel } from './getLabel';// Wrong: a new test file written in the older style of the test it mirrors. A// file you create follows the rules, whatever style the mirrored test uses.let name: string;describe('getLabel', () => {beforeEach(() => {name = ' Ada ';});test('trims the name it is given', () => {expect(getLabel({ name })).toBe('Ada');});});
Correct
import { expect, describe, test } from '@jest/globals';import { getLabel } from './getLabel';// Right: a new test file follows the rules. It covers what the older test it// mirrors covers, and takes none of that test's structure.const setupLabel = ({ name = ' Ada ' }: { name?: string } = {}) => {return { name };};describe('getLabel', () => {test('trims the name it is given', () => {const { name } = setupLabel();const label = getLabel({ name });expect(label).toBe('Ada');});});
Configure
- Block
"blocking"Stops a run when a file the run changed breaks the rule. - AdviseDefault
"advisory"Reports it and hands it to the refactor agent. Never stops a run. - Off
"off"Not checked. Use it when your own linter already enforces the rule.
Add this to your lightsout.config.json, then change the value.
{"standards-rule-settings": {"existing-tests": "advisory"}}