December 2015
Intermediate to advanced
240 pages
4h 57m
English
Matchers are used to compare the expected and actual values or validation of the expected value. If a matcher is going to compare the expected value, it takes actual value as argument. Matchers are chained with expectations. There are a number of matchers provided by Jasmine. Here is a list of all matchers:
toBe(): This matcher compares using the identity (= = =) operator.var a = 5;
expect(a).toBe(5);
expect(a).not.toBe("5");The difference between the identity operator (= = =) and equality operator (= =) is that in identity operator, no type conversion is done before comparison.
toEqual(): This matcher is used to compare simple literals, variables, and functions.expect(a).toEqual(5); // checking for simple variables. expect(a).not.toEqual(3); ...
Read now
Unlock full access