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