jquery-expect
jquery-expect copied to clipboard
Bug: Unexpected error when background-color is not defined
The error Cannot read properties of null (reading ‘1’) is given when the background-color property is not defined. For example, consider
$expect('body').to.have.css('background-color', '#f9f9f9', 'Did you apply a background color of `#f9f9f9` to the `body`?');
It works as expected when it is defined correctly or incorrectly; it gives the intended error message. However, if the background-color property is missing altogether, it gives the null message.
I'm not sure how many (or which) properties this bug affects but it doesn't happen with the color property. If I have a statement like this:
$expect('.subtitle').to.have.css(' color', '#333333', '`color` is not set to `#333333`.');
It displays the defined error message if the color property doesn't exist or isn't set correctly instead of null error.
I believe that's the expected behavior but I could be wrong. I'm just creating this issue for awareness. As per my Slack thread, we've gotten around this by using getComputedStyle.