Playwright · Middle · Question 27 of 75

How do you add a custom message to an assertion?

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.

Further reading

Problem with a question

Playwright · Middle · question 27

Test yourself

Take the Playwright · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz