0

How to by using mocha/chai check if elements cssProperty to be x?

This is kind of what i want:

expect(accountText.getCssProperty('color')).to.be('#fff');

This is the error message i get:

expect(...).to.be is not a function
jaikl
  • 971
  • 2
  • 9
  • 23
  • Try *equal*: `expect(accountText.getCssProperty('color')).to.equal('#fff');` – Patrick Hund Sep 17 '18 at 14:08
  • Seems like getCssProperty to look at the value of a selector. This worked: expect(accountText.value.getCssProperty('color')).to.be('#fff'); – jaikl Oct 11 '18 at 13:00
  • Possibly related - [How to test style for a React component attribute with Enzyme](https://stackoverflow.com/q/40795850/104380) – vsync Jun 13 '22 at 10:22

1 Answers1

0

Try it:

expect(accountText.getCssProperty('color').value).to.be.equal('#fff');
Munim Munna
  • 17,178
  • 6
  • 29
  • 58
  • 2
    Hi Evgeny. Please can you explain why this solves the "is not a function" error to help the original poster. – Mike Poole Jul 10 '19 at 16:30