📝 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.
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 => {}); // ✅