Skip to content

Instantly share code, notes, and snippets.

@MilanGrubnic70
Last active January 24, 2016 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MilanGrubnic70/742f08c9d49280b78265 to your computer and use it in GitHub Desktop.
Save MilanGrubnic70/742f08c9d49280b78265 to your computer and use it in GitHub Desktop.
Jasmine Cheat Sheet
Matchers Reference
toEqual checks for equality, not necessarily the same object.
toBe checks if two objects are the same.
toBeTruthy checks if a value is truthy (not just true).
toBeFalsy checks if a value is falsy (not just false).
toContain checks if a value is inside another.
toBeDefined checks if a value is defined.
toBeUndefined checks if a value is undefined.
toBeNull checks if a value is null.
toBeNaN checks if a value is NaN.
toBeCloseTo checks decimal proximity.
toMatch checks if a value matches a given regular expression.
toThrow checks if a function throws an error.
.not inverts the meaning of the following matcher.
List of Falsy Values
false
0
""
undefined (note that the variable undefined isn’t always undefined!)
null
NaN
Reserved Words in Jasmine
The following are words that you shouldn’t use in your code so that you don’t cause conflicts with Jasmine:
jasmine (and everything in its namespace)
describe
it
expect
beforeEach
afterEach
runs
waits
waitsFor
spyOn
xdescribe
xit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment