no-duplicate-assertions

July 3, 2026 ยท View on GitHub

๐Ÿ“ Disallow adjacent duplicate assertions.

๐Ÿ’ผ This rule is enabled in the following configs: โœ… recommended, โ˜‘๏ธ unopinionated.

Repeating the same assertion twice in a row is usually a copy-paste leftover and does not verify anything new.

This rule only reports adjacent identical assertion statements inside a test body. Later repeats are allowed so tests can assert that a value stayed stable across an operation. Assertions are compared by canonical method and normalized argument source, so assert(value) and assert.ok(value) are equivalent.

Examples

import test from 'node:test';
import assert from 'node:assert/strict';

// โŒ
test('user', () => {
	assert.strictEqual(user.id, 1);
	assert.strictEqual(user.id, 1);
});

// โœ…
test('user is stable after update', () => {
	assert.strictEqual(user.id, 1);
	update(user);
	assert.strictEqual(user.id, 1);
});