DOM-less simple JavaScript testing framework
|
describe( label, function(){ ... })
group tests together
|
|
it( label, function(){ ... })
label individual test
|
|
expect( actual )
used to compare against expected values
|
|
beforeEach(function(){ ... })
run prior to each it in the describe
|
|
afterEach(function() { ... })
run after each it in the describe
|
|
xdescribe( label, function(){ ... })
skip section ( note the x )
|
|
xit( label, function(){ ... })
skip test ( note the x )
|
|
to(Not)Be( null | true | false )
|
|
to(Not)Equal( value )
|
|
to(Not)Match( regex | string )
|
|
toBeDefined()
|
|
toBeUndefined()
|
|
toBeNull()
|
|
toBeTruthy()
|
|
toBeFalsy()
|
|
to(Not)Contain( string )
|
|
toBeLessThan( number )
|
|
toBeGreaterThan( number )
|
|
toBeNaN()
|
|
toBeCloseTo( number, precision )
|
|
toThrow()
|
|
spyOn( obj, method_string )
|
|
obj.stubbed.calls
array
|
|
obj.stubbed.mostRecentCall
call object
|
|
obj.stubbed.calls[0].args
array
|
|
toHaveBeenCalled()
|
|
toHaveBeenCalledWith( array )
|
|
andCallThrough()
spy and delegate to real object
|
|
andReturn( value )
|
|
andCallFake(function() { ... })
|
|
jasmine.createSpy( id )
|
|
jasmine.createSpyObj( baseName, methods[] )
|
|
jasmine.any( constructor )
|
Thanks! great list, the syntax is outdated. spyOn now uses dot for callThrough and returnValue such that .andCallThrough became .and.callThrough
Beware, this cheat sheet contain hidden characters, so direct copy paste to Visual Studio will result in "Uncaught SyntaxError: Unexpected token ILLEGAL" exception when running JavaScript in the Browser.
Helpfull cheat sheet, Thank you.
"ddescribe" and "iit" were renamed to "fdescribe" and "fit". (The f standing for focus)
The list is not complete. There are no "ddescribe", "iit" and perhaps other methods.
Can you create a cheat sheet for Jasmine 2.x?
Thank you! :)
Thanks.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.