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 => {});        // βœ