test" /> test" /> test"/>

Cypress checking line-through

405 views Asked by At

I have a web page where the items when checked get a line-through as in the image below.

Before checking:

<li style="text-decoration: none;">test</li>

After checking:

<li style="text-decoration: line-through;">test</li>

enter image description here

I am trying to assert on the line-though with :

cy.get('li').should('have.css', 'text-decoration', 'line-through')

But, I get this error on assertion :

assertexpected <li> to have CSS property text-decoration with the value line-through, but the value was line-through solid rgb(0, 0, 0)

How do I assert on the line-through?

1

There are 1 answers

0
Fody On BEST ANSWER

You need a partial check.

I know this works Cypress.$(e).css('text-decoration').includes('line-through') so perhaps this:

cy.get('li')
  .invoke('css', 'text-decoration')
  .should('include', 'line-through')