Just Test It
Karma, Mocha, Sinon.js

Artyom Trityak
Why test?
It’s impossible to do regression testing for big projects
Want to do refactoring - test it!
Want to deploy each sprint - test it!
Want to show how to use your module - test it!
What test?
Business logic
What test?
Business logic where?

Models
Controllers
Views
What test?
Business logic
Models
Controllers
What test?
Business logic
Models
Controllers
Shared functionality (base classes, utils etc)
How test: Karma
Runs your unittests in different browsers automatically:
Chrome, Phantomjs, Firefox, Safari, IE
Run-on-change
Test in real devices: phones, tablets etc
How test: Karma
How test: Sinon.js
Mock modules dependencies
Mock backend requests and responses
Mock / stub methods and objects
Check methods calledWith and callCount
How test: Sinon.js
How test: Mocha+Chai
or Jasmine

Test async behaviors
Different reports
Both fine: Mocha+Chai or Jasmine (2.0 is out)
Jasmine 2.0 supports Mocha-style «done» callback for
async tests
How test: Mocha+Chai
or Jasmine
How test: Mocha+Chai
or Jasmine
How test: Require.js
Test modular code
Clean state for each test
How test: Require.js
FrontendLab: Воркшоп "Just Test It". Артем Тритяк, Electric Cloud

FrontendLab: Воркшоп "Just Test It". Артем Тритяк, Electric Cloud