Jasmine is false positive with {} and [] in jasmine - node

For some reason, jasmine ...

expect({}).toEqual([]);

      

communicates the truth (but they are different). How to do it with jasmine?

+3


source to share


3 answers


You can move the equality check within the proposal expect

:



a = {}
b = []
expect(a === b).toBeTruthy();

      

+1


source


With lodash, you can do this:



expect( _.isEqual(a, b) ).toBe( false );

0


source


Take a look at the JasmineMatchers project . He adds coincidences, such as toBeEmptyObject

and toBeArray

and toBeEmptyArray

many others.

0


source







All Articles