1

I have a Jasmine test like this:

expect(array.length).toEqual(0);

This passes. Out of curiosity I changed it to:

expect(array.length).toEqual(false);

This test fails. I was under the impression that the toEqual method does a not-strict comparison. If we do

console.log(0 == false);

We get the output

true

So why is this test failing?

dz210
  • 748
  • 1
  • 8
  • 20

1 Answers1

0

Answering my own question after research: jasmine adapts underscore's isEqual method, which does a deep comparison to determine if objects should be equal. So it is a more robust comparison than javascript's standard == comparison.

dz210
  • 748
  • 1
  • 8
  • 20