useExpect
Ta treść nie jest jeszcze dostępna w Twoim języku.
Summary
Section titled “Summary”- Rule available since:
v2.4.2 - Diagnostic Category:
lint/nursery/useExpect - This rule doesn’t have a fix.
- The default severity of this rule is information.
- This rule belongs to the following domains:
- Sources:
- Same as
playwright/expect-expect - Same as
jest/expect-expect - Same as
vitest/expect-expect
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useExpect": "error" } } }}Description
Section titled “Description”Ensure that test functions contain at least one expect() assertion.
Tests without assertions may pass even when behavior is broken, leading to
false confidence in the test suite. This rule ensures that every test
validates some expected behavior using expect().
Examples
Section titled “Examples”Invalid
Section titled “Invalid”test("no assertion", async ({ page }) => { await page.goto("/"); await page.click("button");});code-block.js:1:1 lint/nursery/useExpect ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ℹ Test callback is missing an expect() assertion.
> 1 │ test(“no assertion”, async ({ page }) => {
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 2 │ await page.goto(”/”);
> 3 │ await page.click(“button”);
> 4 │ });
│ ^^
5 │
ℹ Tests without assertions may pass even when the behavior is broken.
ℹ Add an assertion using expect() to verify the expected behavior.
ℹ 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.
test("has assertion", async ({ page }) => { await page.goto("/"); await expect(page).toHaveTitle("Title");});test("soft assertion", async ({ page }) => { await page.goto("/"); await expect.soft(page.locator("h1")).toBeVisible();});Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.