useConsistentTestIt
Esta página aún no está disponible en tu idioma.
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/useConsistentTestIt - This rule has a safe fix.
- The default severity of this rule is warning.
- This rule belongs to the following domains:
- Sources:
- Inspired from
jest/consistent-test-it - Inspired from
vitest/consistent-test-it
- Inspired from
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useConsistentTestIt": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”test("foo", () => {});code-block.js:1:1 lint/nursery/useConsistentTestIt FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Prefer using it over test for test functions.
> 1 │ test(“foo”, () => {});
│ ^^^^
2 │
ℹ Use it consistently for all test function calls.
ℹ 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", () => {});Options
Section titled “Options”function
Section titled “function”The function to use for top-level tests (outside describe blocks).
Accepted values are:
"it"(default): Enforce usingit()for top-level tests"test": Enforce usingtest()for top-level tests
{ "linter": { "rules": { "nursery": { "useConsistentTestIt": { "options": { "function": "test" } } } } }}Invalid
Section titled “Invalid”it("foo", () => {});code-block.js:1:1 lint/nursery/useConsistentTestIt FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Prefer using test over it for test functions.
> 1 │ it(“foo”, () => {});
│ ^^
2 │
ℹ Use test consistently for all test function calls.
ℹ 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", () => {});withinDescribe
Section titled “withinDescribe”The function to use for tests inside describe blocks.
Accepted values are:
"it"(default): Enforce usingit()inside describe blocks"test": Enforce usingtest()inside describe blocks
{ "linter": { "rules": { "nursery": { "useConsistentTestIt": { "options": { "withinDescribe": "test" } } } } }}Invalid
Section titled “Invalid”describe("suite", () => { it("foo", () => {});});code-block.js:2:5 lint/nursery/useConsistentTestIt FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Prefer using test over it for test functions.
1 │ describe(“suite”, () => {
> 2 │ it(“foo”, () => {});
│ ^^
3 │ });
4 │
ℹ Use test consistently for all test function calls.
ℹ 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", () => {});});Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.