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);