Repository URL to install this package:
|
Version:
0.6.0 ▾
|
gateway-proxy
/
usr
/
share
/
gateway-proxy
/
app
/
node_modules
/
eslint-plugin-jest
/
docs
/
rules
/
consistent-test-it.md
|
|---|
test and it usages (consistent-test-it)💼 This rule is enabled in the following
configs:
all.
🔧 This rule is automatically fixable using the --fix
option
on the command line.
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, xit, fit, it.only, it.skip.test, xtest, test.only, test.skip.This rule gives you control over the usage of these keywords in your codebase.
This rule can be configured as follows
{
type: 'object',
properties: {
fn: {
enum: ['it', 'test'],
},
withinDescribe: {
enum: ['it', 'test'],
},
},
additionalProperties: false,
}
Decides whether to use test or it.
Decides whether to use test or it within a describe scope.
/*eslint jest/consistent-test-it: ["error", {"fn": "test"}]*/ test('foo'); // valid test.only('foo'); // valid it('foo'); // invalid it.only('foo'); // invalid
/*eslint jest/consistent-test-it: ["error", {"fn": "it"}]*/ it('foo'); // valid it.only('foo'); // valid test('foo'); // invalid test.only('foo'); // invalid
/*eslint jest/consistent-test-it: ["error", {"fn": "it", "withinDescribe": "test"}]*/ it('foo'); // valid describe('foo', function () { test('bar'); // valid }); test('foo'); // invalid describe('foo', function () { it('bar'); // invalid });
The default configuration forces all top-level tests to use test and all tests
nested within describe to use it.
/*eslint jest/consistent-test-it: ["error"]*/ test('foo'); // valid describe('foo', function () { it('bar'); // valid }); it('foo'); // invalid describe('foo', function () { test('bar'); // invalid });