Skip to content

Latest commit

 

History

History
59 lines (44 loc) · 1.12 KB

expect-expect.md

File metadata and controls

59 lines (44 loc) · 1.12 KB

Enforce assertion to be made in a test body (expect-expect)

Ensure that there is at least one expect call made in a test.

Rule Details

Examples of incorrect code for this rule:

test('should be a test', () => {
  console.log('no assertion')
})

test('should assert something', () => {})

Examples of correct code for this rule:

test('should be a test', async () => {
  await expect(page).toHaveTitle('foo')
})

test('should work with callbacks/async', async () => {
  await test.step('step 1', async () => {
    await expect(page).toHaveTitle('foo')
  })
})

Options

{
  "playwright/expect-expect": [
    "error",
    {
      "assertFunctionNames": ["assertCustomCondition"]
    }
  ]
}

assertFunctionNames

This array option specifies the names of functions that should be considered to be asserting functions.

/* eslint playwright/expect-expect: ["error", { "assertFunctionNames": ["assertScrolledToBottom"] }] */

function assertScrolledToBottom(page) {
  // ...
}

test('should scroll', async ({ page }) => {
  await assertScrolledToBottom(page)
})