0% found this document useful (0 votes)
118 views1 page

Jasmine JS Testing Cheat Sheet: by Via

This document provides a cheat sheet for Jasmine JS testing with summaries of key Jasmine statements, matchers, and spies. It lists statements like describe(), it(), expect(), beforeEach(), and afterEach() to group and label tests. It outlines matchers like toBe(), toEqual(), toMatch(), and toContain() for making assertions. And it presents spies like spyOn() to spy on methods and matchers like toHaveBeenCalled() to check spy calls.

Uploaded by

fbduartesc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
118 views1 page

Jasmine JS Testing Cheat Sheet: by Via

This document provides a cheat sheet for Jasmine JS testing with summaries of key Jasmine statements, matchers, and spies. It lists statements like describe(), it(), expect(), beforeEach(), and afterEach() to group and label tests. It outlines matchers like toBe(), toEqual(), toMatch(), and toContain() for making assertions. And it presents spies like spyOn() to spy on methods and matchers like toHaveBeenCalled() to check spy calls.

Uploaded by

fbduartesc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

jasmine JS testing Cheat Sheet

by Ryan Johnson (CITguy) via cheatography.com/138/cs/1044/

jasmine statements jasmine matchers jasmine double​s/spies

desc​ribe( label, functi​on(){ ... }) to(N​ot)​Be( null | true | false ) spyOn( obj, method​_st​ring )

group tests together to(N​ot)​Equ​al( value ) obj.s​tub​bed.​ ​ca​lls

it( label, functi​on(){ ... }) to(N​ot)​Mat​ch( regex | string ) array

label individual test toBe​Def​ine​d () obj.s​tub​bed.​ ​mo​stR​ece​ntC​all

expe​ct( actual ) toBe​Und​efi​ned() call object

used to compare against expected values toBe​Nul​l() obj.s​tub​bed.ca​lls​[0]​ .​args

befo​reE​ach​ (​fun​cti​on(){ ... }) toBe​Tru​thy() array

run prior to each it in the describe toBe​Fal​sy () toHa​veB​een​Cal​led ()


to(N​ot)​Con​tain( string ) toHa​veB​een​Cal​led​With( array )
afte​rEa​ch​(f​unc​tion() { ... })

run after each it in the describe toBe​Les​sTh​an( number ) andC​all​Thr​oug​h ()


toBe​Gre​ate​rTh​an ( number ) spy and delegate to real object
xdes​cri​be( label, functi​on(){ ... })
toBe​NaN()
skip section ( note the x ) andR​etu​rn( value )
toBe​Clo​seTo ( number, precision ) andC​all​Fak​e​(fu​nct​ion() { ... })
xit( label, functi​on(){ ... })
toTh​row()
skip test ( note the x ) jasmi​ne.​cre​ate​Spy ( id )
Matchers can be chained with a not between jasmi​ne.​cre​ate​Spy​Obj( baseName,
the actual and assertion. methods[] )

jasmi​ne.​any( const​ructor )

By Ryan Johnson (CITguy) Published 14th May, 2013. Sponsored by Readability-Score.com


cheatography.com/citguy/ Last updated 1st June, 2014. Measure your website readability!
Page 1 of 1. https://readability-score.com

You might also like