Skip to content

useConsistentTestIt

biome.json
{
"linter": {
"rules": {
"nursery": {
"useConsistentTestIt": "error"
}
}
}
}

Enforce consistent use of it or test for test functions.

it and test are aliases for the same function in most test frameworks. This rule enforces using one over the other for consistency.

test("foo", () => {});
code-block.js:1:1 lint/nursery/useConsistentTestIt  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The test function test is inconsistent with the configured preferred function it.

> 1 │ test(“foo”, () => {});
^^^^
2 │

Using a consistent function for tests improves readability and makes it easier to search for tests in the codebase.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

Safe fix: Use it instead.

1 - test(foo,·()·=>·{});
1+ it(foo,·()·=>·{});
2 2

it("foo", () => {});

The function to use for top-level tests (outside describe blocks). Accepted values are:

  • "it" (default): Enforce using it() for top-level tests
  • "test": Enforce using test() for top-level tests
biome.json
{
"linter": {
"rules": {
"nursery": {
"useConsistentTestIt": {
"options": {
"function": "test"
}
}
}
}
}
}
it("foo", () => {});
code-block.js:1:1 lint/nursery/useConsistentTestIt  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The test function it is inconsistent with the configured preferred function test.

> 1 │ it(“foo”, () => {});
^^
2 │

Using a consistent function for tests improves readability and makes it easier to search for tests in the codebase.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

Safe fix: Use test instead.

1 - it(foo,·()·=>·{});
1+ test(foo,·()·=>·{});
2 2

test("foo", () => {});

The function to use for tests inside describe blocks. Accepted values are:

  • "it" (default): Enforce using it() inside describe blocks
  • "test": Enforce using test() inside describe blocks
biome.json
{
"linter": {
"rules": {
"nursery": {
"useConsistentTestIt": {
"options": {
"withinDescribe": "test"
}
}
}
}
}
}
describe("suite", () => {
it("foo", () => {});
});
code-block.js:2:5 lint/nursery/useConsistentTestIt  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The test function it is inconsistent with the configured preferred function test.

1 │ describe(“suite”, () => {
> 2 │ it(“foo”, () => {});
^^
3 │ });
4 │

Using a consistent function for tests improves readability and makes it easier to search for tests in the codebase.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

Safe fix: Use test instead.

1 1 describe(“suite”, () => {
2 - ····it(foo,·()·=>·{});
2+ ····test(foo,·()·=>·{});
3 3 });
4 4

describe("suite", () => {
test("foo", () => {});
});