Playwright · Middle · Question 27 of 75
How do you add a custom message to an assertion?
- 1
await expect(total).toHaveText('$10', 'cart total') - 2
await expect(total).toHaveText('$10').message('cart total') - 3
await expect(total, 'cart total').toHaveText('$10')
Show the answer
Correct answer: await expect(total, 'cart total').toHaveText('$10')
Explanation
The message appears in the report and makes failures easier to understand without opening the code.