ntnyq/no-only-tests
Disallow use
.onlyblocks in tests.
- 🔧 The
--fixoption on the command line can automatically fix some of the problems reported by this rule.
📖 Rule Details
This rule reports while using .only blocks in tests.
ts
describe('some describe block', () => {})
it('some assertion', () => {})
other.only('this is allowed by default', () => {})correct
ts
describe.only('focused suite', () => {})
it.only('focused case', () => {})
test.only('focused test', () => {})incorrect
🔧 Options
ts
export type Options = [
{
block?: string[]
focus?: string[]
functions?: string[]
fix?: boolean
},
]Defaults:
block:['describe', 'it', 'context', 'test', 'tape', 'fixture', 'serial', 'Feature', 'Scenario', 'Given', 'And', 'When', 'Then']focus:['only']functions:[]fix:false
block
List of block names that should not be focused. Wildcard suffix * is supported.
ts
// options: [{ block: ['test*'] }]
testResource.only('resource test', () => {})focus
List of focus method names.
ts
// options: [{ focus: ['focus'] }]
test.focus('focused test', () => {})functions
List of direct function names to disallow.
ts
// options: [{ functions: ['fit', 'xit'] }]
xit('skipped test', () => {})fix
When true, the rule removes focus method usage such as .only or .focus.
🚀 Version
This rule was introduced in eslint-plugin-ntnyq v0.15.0