Skip to content

Instantly share code, notes, and snippets.

@shinypb
Forked from Rafe/gist:2289021
Last active August 29, 2015 14:08
Show Gist options
  • Save shinypb/014c80a45c3049e36b64 to your computer and use it in GitHub Desktop.
Save shinypb/014c80a45c3049e36b64 to your computer and use it in GitHub Desktop.
expect(x).toEqual(y); compares objects or primitives x and y and passes if they are equivalent
expect(x).toBe(y); compares objects or primitives x and y and passes if they are the same object
expect(x).toMatch(pattern); compares x to string or regular expression pattern and passes if they match
expect(x).toBeDefined(); passes if x is not undefined
expect(x).toBeUndefined(); passes if x is undefined
expect(x).toBeNull(); passes if x is null
expect(x).toBeTruthy(); passes if x evaluates to true
expect(x).toBeFalsy(); passes if x evaluates to false
expect(x).toContain(y); passes if array or string x contains y
expect(x).toBeLessThan(y); passes if x is less than y
expect(x).toBeGreaterThan(y); passes if x is greater than y
expect(function(){fn();}).toThrow(e); passes if function fn throws exception e when executed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment