ava/no-invalid-modifier-chain
February 9, 2026 Β· View on GitHub
π Disallow invalid modifier chains.
πΌ This rule is enabled in the β
recommended config.
π§π‘ This rule is automatically fixable by the --fix CLI option and manually fixable by editor suggestions.
Translations: FranΓ§ais
AVA only allows specific test modifier chains. Using modifiers in the wrong order, combining incompatible modifiers, or using modifiers that don't apply to a given test type will cause runtime errors.
Examples
import test from 'ava';
// Wrong order
test.only.serial(t => {}); // β
test.serial.only(t => {}); // β
test.failing.serial(t => {}); // β
test.serial.failing(t => {}); // β
// Invalid combinations
test.only.skip(t => {}); // β
// Invalid modifiers on hooks
test.before.failing(t => {}); // β
test.before.only(t => {}); // β
test.before(t => {}); // β
// Invalid todo chains
test.todo.failing('title'); // β
test.todo('title'); // β
// Invalid always usage
test.before.always(t => {}); // β `.always` only works with `after`/`afterEach`
test.after.always(t => {}); // β
test.afterEach.always(t => {}); // β
// Unknown modifiers
test.foo(t => {}); // β
test.cb(t => {}); // β
// Duplicates
test.serial.serial(t => {}); // β
test.serial(t => {}); // β