consistent-test-it
Added in v0.9.4Configuration
Rule Details
Jest allows you to choose how you want to define your tests, using the it or the test keywords, with multiple permutations for each:
- it:
it,xit,fit,it.only,it.skip. - test:
test,xtest,test.only,test.skip.
This rule gives you control over the usage of these keywords in your codebase. By default, it requires test for top-level tests and it for tests nested within a describe. It is fixable.
Options
This rule accepts an object with the following properties:
fn("it"or"test"): decides whether to usetestorit.withinDescribe("it"or"test"): decides whether to usetestoritwithin adescribescope. When omitted, it takes the value offn, or"it"iffnis not set either.
With the default configuration:
Differences from upstream
The diagnostics are the same as upstream. The fix differs in three ways.
When a test call has more than one member after its name, the fix keeps all of them. Upstream drops every member except the last:
When the call comes from an @jest/globals import, the fix also imports the new name, or reuses an existing import of it. Upstream calls the new name without importing it, which fails when injectGlobals is false:
No fix is offered when the new name would not reach the Jest API: when a local variable, parameter or other declaration with that name is in scope, when the file already declares it some other way (such as an import from another module), when the call comes from a let or var binding of a CommonJS require, which may have been reassigned, or when it comes from any other require binding and the file does not already import the new name. Upstream calls whatever that name refers to: