biome nursery/useConsistentTestIt: fix changes program behavior
Hypothesis Nemotron 3 Super predicted to fire fired 2×
ASI and semicolon-less code, leading ( or [ on the next line
Program
Output
(no stdout) ReferenceError: test is not defined
(no stdout) ReferenceError: it is not defined
- fired
- 2 before · 0 after
- runs
- each version twice, same file name, no network
Judge Nemotron 3 Ultra advisory real · high
The rule assumes `it` and `test` are globally available aliases, but the program runs in an environment where neither is defined. The fix rewrites `test` to `it`, changing only the name of the missing global, so the runtime error persists with a different identifier. This is a silent semantic change in plausible code because the rule's documentation presents the rewrite as equivalent while the construct (using a test function without a test runner) is legal JavaScript.
Explanation Nemotron 3 Super unverified
The original code calls `test` functions; after rewriting to `it`, those identifiers refer to different variables or properties that may be undefined in scope, causing a reference error where none occurred before—or changing which function is invoked if both exist—altering execution flow and observable behavior. Since `test` ≠ `it`, the substitution changes what code runs, violating semantic equivalence. No assumption about scoping or definitions can make this rewrite safe without contextual guarantees. Thus, the fix is not semantics-preserving.
Reproduce
- file
prog.js(the before program)- minimized program
- r2-p003.js
- evidence sheet
- r2-p003.md
- regression fixture
- r2-p003.js the minimized program with a header stating the observed change, for the tool's test suite
node prog.js bunx @biomejs/biome lint --only=nursery/useConsistentTestIt --write prog.js node prog.js
Upstream search GitHub issues Tavily Nemotron 3 Super + Ultra
useConsistentTestIt fix · nursery/useConsistentTestIt test function call · useConsistentTestIt replace test with it · biome lint nursery/useConsistentTestIt array map
- related biomejs/biome/issues/11453 same rule but different construct: imported binding vs global identifier
- related biomejs/biome/pull/9350 same rule (useConsistentTestIt) but PR introducing the rule, not a defect report
- related biomejs/biome/pull/9942 same rule but fix for panic during fix application, not fix-changes-behavior
Details
- program
- ASI Leading Parenthesis
- hazard
- ASI and semicolon-less code, leading ( or [ on the next line
- oracle
stderr before: ReferenceError: test is not defined stderr after: ReferenceError: it is not defined- run
- 2026-10-17T20-49-46-686Z-qbws-biome-nursery_useConsistentTestIt
generated program (3 lines) and the fix's diff
--- orig.js 2026-10-17 16:50:08.094281251 -0400 +++ fixed.js 2026-10-17 16:50:08.387287016 -0400 @@ -1,3 +1,3 @@ let x = 1 -[test('first', () => x++), test('second', () => x++)].forEach(f => f()) +[it('first', () => x++), it('second', () => x++)].forEach(f => f()) console.log(x)
rule documentation given to the models
Summary
- Name: useConsistentTestIt
- Fix: safe
- Default severity: warn
- Available from version: 2.4.11
- Diagnostic category: lint/nursery/useConsistentTestIt
Domains
- Name: test
- The rule is enabled when one of these dependencies are detected:
- jest@>=26.0.0
- mocha@>=8.0.0
- ava@>=2.0.0
- vitest@>=1.0.0
- The rule adds the following globals:
- after
- afterAll
- afterEach
- before
- beforeEach
- beforeAll
- context
- describe
- it
- expect
- run
- setup
- specify
- suite
- suiteSetup
- suiteTeardown
- teardown
- test
- xcontext
- xdescribe
- xit
- xspecify
Description
Enforce consistent use of `it` or `test` for test functions.
`it` and `test` are aliases for the same function in most test frameworks.
This rule enforces using one over the other for consistency.
Imported functions keep their original export through an import alias.
The fix is unavailable when the preferred name conflicts with another binding or global reference.
Examples
Invalid
```js,expect_diagnostic
test("foo", () => {});
```
Valid
```js
it("foo", () => {});
```
Options
`function`
The function to use for top-level tests (outside `describe` blocks).
Accepted values are:
- `"it"` (default): Enforce using `it()` for top-level tests
- `"test"`: Enforce using `test()` for top-level tests
```json,options
{
"options": {
"function": "test"
}
}
```
Invalid
```js,use_options,expect_diagnostic
it("foo", () => {});
```
Valid
```js,use_options
test("foo", () => {});
```
`withinDescribe`
The function to use for tests inside `describe` blocks.
Accepted values are:
- `"it"` (default): Enforce using `it()` inside describe blocks
- `"test"`: Enforce using `test()` inside describe blocks
```json,options
{
"options": {
"withinDescribe": "test"
}
}
```
Invalid
```js,use_options,expect_diagnostic
describe("suite", () => {
it("foo", () => {});
});
```
Valid
```js,use_options
describe("suite", () => {
test("foo", () => {});
});
```