Playwright · Senior · Question 30 of 77
How do you add a custom matcher like toHaveCartTotal?
- 1Use
expect.extendand export the extendedexpect - 2Custom matchers are only possible in Jest, not Playwright
- 3Add a method to
Locator.prototypein the config
Show the answer
Correct answer: Use expect.extend and export the extended expect
Explanation
Custom matchers can be async and use locators, giving readable domain checks with good failure messages.