Jasmine: Matcher to be different from undefined and diferent from null (!= undefined and != null)
Solution 1:
Fails if context is null or undefined. This better way for checking existing
expect(context).toEqual(jasmine.anything());
Solution 2:
Just use .toEqual()
:
expect(context).not.toEqual(null);
In Javascript undefined == null
is true
, so this test will exclude both undefined
and null
.