consistent-test-context-name
July 23, 2026 ยท View on GitHub
๐ Enforce a consistent name for the test context parameter.
๐ผ This rule is enabled in the following configs: โ
recommended, โ๏ธ unopinionated.
The test and subtest callbacks receive a test context object, conventionally named t (test('โฆ', t => {})). Using a consistent name keeps t.assert, t.mock, t.test, and t.plan recognizable across a codebase.
This rule reports a test/it (or subtest) callback whose first parameter is named something other than the configured name, including one with a default value ((context = โฆ) => {}). Callbacks with no parameter, or that destructure the context, are left alone.
Options
name(string, default't') โ the required parameter name.
{
'node-test/consistent-test-context-name': [
'error',
{
name: 't'
}
]
}
Examples
import test from 'node:test';
// โ
test('reads a file', context => {
context.assert.ok(result);
});
// โ
test('reads a file', t => {
t.assert.ok(result);
});