require-assertion
July 14, 2026 Β· View on GitHub
π Require that each test contains at least one assertion.
πΌπ« This rule is enabled in the β
recommended config. This rule is disabled in the βοΈ unopinionated config.
A test without any assertions will always pass, even if the code under test is broken. This rule requires each test/it call to contain at least one assertion from node:assert, the test context's assert property, or the assert property directly destructured from the test callback parameter.
Note: Tests that reference an external implementation (without an inline function body) are not flagged, since the implementation may contain assertions.
Examples
import test from 'node:test';
import assert from 'node:assert';
// β
test('foo', () => {
doSomething();
});
// β
test('foo', () => {});
// β
test('foo', () => {
assert.strictEqual(result, expected);
});
// β
test('foo', t => {
t.assert.ok(value);
});
// β
test('foo', ({assert}) => {
assert.ok(value);
});
// β
β external implementation, may contain assertions
test('foo', implementation);