Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom message for failed assertion in playwright (using cucumber.js)

In project I use node js 20.5.1, playwright 1.37. with cucumber 8.0.0. I want to add own customer message if expected method return me a failed. I thought I could do it like below:

expect(3),"My custom message").toBeLessThanOrEqual(2);

And in test result I should for that step Error: My custom message,

,but I only see

Error: expect(received).toBeLessThanOrEqual(expected)

Do you know how I could handled with that ? :) Thanks for any tips :)

like image 296
Marcin Avatar asked Jun 13 '26 05:06

Marcin


1 Answers

It seems like your error refers to another line of code. Anyway, in order to add a custom message to expect statement you should use:

await expect(page.getByText('Name'), 'should be logged in').toBeVisible();

as you can see in their official documentation here

like image 145
OrnaZ Avatar answered Jun 16 '26 11:06

OrnaZ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!