Jasmine Matchers
So far you’ve only seen toEqual as a core Jasmine matcher, but Jasmine defines quite a few. Here are the built-in matchers.
Matcher | Passes if |
---|---|
toBe(actual) | expected === actual (JavaScript triple equal). |
toBeCloseTo(actual, precision) | The floating-point value of actual is within precision amount of the expected value. |
toBeGreaterThan(actual) | expected > actual. |
toBeFalsy() | The expected value is a JavaScript falsy value. |
toBeLessThan(actual) | expected < actual. |
toBeNull() | The expected value is null. |
toBeTruthy() | The expected value is a JavaScript truthy value. |
toBeUndefined() | The expected value is undefined; no actual argument needed. |
toContain(actual) | expected is an array that contains the actual value. |
toEqual(actual) | expected and actual are equal values. ... |
Get Rails 5 Test Prescriptions now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.