consistent-test-it

July 2, 2026 ยท View on GitHub

๐Ÿ“ Enforce consistent use of test or it.

๐Ÿšซ This rule is disabled in the following configs: โœ… recommended, โ˜‘๏ธ unopinionated.

test and it are aliases. Mixing them in a codebase is purely cosmetic noise โ€” it usually signals copy-pasted code or inconsistent conventions. This rule enforces a single choice, optionally a different one at the top level versus inside a describe (the common test() / describe(() => it()) style).

Options

{
	'node-test/consistent-test-it': ['error', {
		fn: 'test', // 'test' | 'it' โ€” name for top-level test cases (default: 'test')
		withinDescribe: 'it', // 'test' | 'it' โ€” name inside a `describe` (default: 'it')
	}]
}

Examples

With the defaults (fn: 'test', withinDescribe: 'it'):

import {test, it, describe} from 'node:test';

// โŒ
it('runs', () => {}); // top level should use `test`

describe('group', () => {
	test('runs', () => {}); // inside `describe` should use `it`
});

// โœ…
test('runs', () => {});

describe('group', () => {
	it('runs', () => {});
});