Cypress · Middle · Question 77 of 77

How do you assert a CSS property, like a colour?

Show the answer

Correct answer: .should('have.css', 'color', 'rgb(255, 0, 0)')

Explanation

Browsers report computed colours as rgb(). Checking style is fragile; use it for important visual states.

Further reading

Problem with a question

Cypress · Middle · question 77

Test yourself

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

Take this quiz