Mocha, chai and sinon

Preview:

Citation preview

Mocha,  Chai  and  Sinon  

               @adstage                @adstage

Andrew  Dixon  andrew@adstage.io

               @adstage

Senior  So(ware  Engineer  at  AdStage  Has  been  launching  companies  since  the  last  millennium.  Worked  on  everything  from  the  Linux  Kernel  to  AmbiBous  SPAs  with  Ember.

Andrew Dixon

RAISEDAdStage  All-­‐In-­‐One  Ad  PlaHorm  Build,  deploy  &  manage  ad  campaigns  across  Google,  Bing,  Facebook,  TwiOer  &  LinkedIn.  

               @adstage

“The only thing we know about the future is that it will be different.”

-­‐  Peter  Drucker

               @adstage

Cassandra

Rails

Postgres

Pros  

*  Stable  -­‐  first  release  in  2008  

*  Large  Community  

*  IntegraBons  

Cons  

 *  Syntax      

 *  ConfiguraBon          (e.g.  asserBon  libraries)  

 *  Asynchronous  TesBng    

 *  Headless  Run  Support  

Pros  

*  NodeJS  NaBve        (i.e.  headless  out  of  the  box)  

*  ExcepBon  on  Failure        (only  req.  for  asserBon  lib)  

*  Asynchronous  TesBng

Cons  

*  Support        (i.e.  no  Ember  happy  path)  

*  IntegraBons  

Sandbox  

*  Great  for  OrganizaBon  

*  Call  `restore()`  Once

Spies  

*  Records  arguments,        return  values  and        excepBons  

*  Wrap  ExisBng        or  Anonymous  

*  Maintains  Behavior

Stubs  

*  Spies  with  Defined        Behavior  

*  Does  Not  Call        ExisBng  FuncBon  

*  Useful  for  Forcing        Errors

Mocks  

*  Stubs  with  Defined        ExpectaBons  

*  Use  Only  for  Method        Under  Test

How  is  AdStage  Tes6ng?• Makefile  to  run  specs  with  NodeJS  

• HBS  Compiled  to  JS  • jsDOM  • RequireJS  to  load  only  the  components  being  tested

How  is  AdStage  Tes6ng?• Makefile  to  run  specs  with  NodeJS  

• HBS  Compiled  to  JS  • jsDOM  • RequireJS  to  load  only  the  components  being  tested

What  About  Ember-­‐CLI?

• InstallaBon  is  Stupid  Easy  

• Specs  are  Transpiled  • Specs  Run  in  the  Browser

What  About  Ember-­‐CLI?

• InstallaBon  is  Stupid  Easy  

• Specs  are  Transpiled  • Specs  Run  in  the  Browser

Recommended