Different behavior from Jest test when run locally and run via npm

808 Views Asked by At

Pretty short question. I'm checking that the opacity of a checkbox is 0 at a particular point in my test. It works perfectly and passes when I run it locally in my IDE (Intellij).

expect(getComputedStyle(checkbox.getDOMNode()).getPropertyValue('opacity')).toBe('0');

However when I run my test via npm t it fails as it finds the opacity to be '' and not '0' as expected.

I also tried

expect(checkbox.getDOMNode()).toHaveStyle('opacity : 0');

and got the same result (i.e. Passes locally and fails when run via npm).

I'm puzzled. Why the difference in test behavior between running locally and via npm ?

0

There are 0 best solutions below