Ensure that there is at least one expect
call made in a test.
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')
})
})
{
"playwright/expect-expect": [
"error",
{
"assertFunctionNames": ["assertCustomCondition"]
}
]
}
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)
})