Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to assert a CSS attribute contains some text in Cypress test? [duplicate]

Tags:

css

cypress

In my Cypress test I'm trying to assert that an element's text is underlined.

I tried to use the below assertion:

homePage.getHeadingWidgetContent().should('have.css', 'text-decoration', 'underline');

But the actual text-decoration is 'underline solid rgba(0, 0, 0, 0.87)');

This below assertion passes:

homePage.getHeadingWidgetContent().should('have.css', 'text-decoration', 'underline solid rgba(0, 0, 0, 0.87)');

Is there a way I can assert that text-decoration includes 'underline'?

like image 878
user9847788 Avatar asked Oct 18 '25 06:10

user9847788


1 Answers

text-decoration is shorthand for a group of properties. You should use one of its constituent properties, specifically text-decoration-line.

homePage.getHeadingWidgetContent().should(
  'have.css', 'text-decoration-line', 'underline'
);
like image 174
szaman Avatar answered Oct 20 '25 00:10

szaman



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!