18
Mocha, Chai and Sinon @adstage @adstage Andrew Dixon [email protected]

Mocha, chai and sinon

Embed Size (px)

Citation preview

Page 1: Mocha, chai and sinon

Mocha,  Chai  and  Sinon  

               @adstage                @adstage

Andrew  Dixon  [email protected]

Page 2: Mocha, chai and sinon

               @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

Page 3: Mocha, chai and sinon

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

-­‐  Peter  Drucker

               @adstage

Page 4: Mocha, chai and sinon

Cassandra

Rails

Postgres

Page 5: Mocha, chai and sinon

Pros  

*  Stable  -­‐  first  release  in  2008  

*  Large  Community  

*  IntegraBons  

Cons  

 *  Syntax      

 *  ConfiguraBon          (e.g.  asserBon  libraries)  

 *  Asynchronous  TesBng    

 *  Headless  Run  Support  

Page 6: Mocha, chai and sinon

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  

Page 7: Mocha, chai and sinon
Page 8: Mocha, chai and sinon
Page 9: Mocha, chai and sinon
Page 10: Mocha, chai and sinon
Page 11: Mocha, chai and sinon

Sandbox  

*  Great  for  OrganizaBon  

*  Call  `restore()`  Once

Page 12: Mocha, chai and sinon

Spies  

*  Records  arguments,        return  values  and        excepBons  

*  Wrap  ExisBng        or  Anonymous  

*  Maintains  Behavior

Page 13: Mocha, chai and sinon

Stubs  

*  Spies  with  Defined        Behavior  

*  Does  Not  Call        ExisBng  FuncBon  

*  Useful  for  Forcing        Errors

Page 14: Mocha, chai and sinon

Mocks  

*  Stubs  with  Defined        ExpectaBons  

*  Use  Only  for  Method        Under  Test

Page 15: Mocha, chai and sinon

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

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

Page 16: Mocha, chai and sinon

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

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

Page 17: Mocha, chai and sinon

What  About  Ember-­‐CLI?

• InstallaBon  is  Stupid  Easy  

• Specs  are  Transpiled  • Specs  Run  in  the  Browser

Page 18: Mocha, chai and sinon

What  About  Ember-­‐CLI?

• InstallaBon  is  Stupid  Easy  

• Specs  are  Transpiled  • Specs  Run  in  the  Browser