ava/no-duplicate-hooks

February 10, 2026 ยท View on GitHub

๐Ÿ“ Disallow duplicate hook declarations.

๐Ÿ’ผ This rule is enabled in the โœ… recommended config.

Disallow multiple hooks of the same type in a test file.

Registering the same hook type multiple times is usually a copy-paste mistake. Both hooks will run, which is confusing and error-prone. Combine the logic into a single hook instead.

Examples

import test from 'ava';

// โŒ
test.before(t => {
	// setup A
});

test.before(t => {
	// setup B
});

// โœ…
test.before(t => {
	// setup A
	// setup B
});