enzymejs / chai-enzyme

Chai.js assertions and convenience functions for testing React Components with enzyme
MIT License
787 stars 72 forks source link

TypeError: to.have.style is not a function #224

Open filipenatanael opened 5 years ago

filipenatanael commented 5 years ago

Hello Everyone,

So I'm getting the below error message when trying to run the tests.

expect(wrapper).to.have.style('background-color').equal('#ccc');

But when I write the code as below, everything works correctly.

expect(wrapper.props().style.backgroundColor).to.be.equal('#ccc');

Any of yours have gone through this before?

kislakiruben commented 5 years ago

@filipenatanael isn't wrapper an enzyme wrapper, so it doesn't have any style actually on it? you should look for the wrapping html element instead for the styles to show.