just test it

16
Just Test It Karma, Mocha, Sinon.js Artyom Trityak

Upload: artyom-trityak

Post on 13-Jul-2015

768 views

Category:

Technology


1 download

TRANSCRIPT

Just Test ItKarma, 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

ControllersViews

What test?Business logic

Models

Controllers

What test?Business logic

Models

Controllers

Shared functionality (base classes, utils etc)

How test: KarmaRuns 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.jsMock modules dependencies

Mock backend requests and responses

Mock / stub methods and objects

Check methods calledWith and callCount

How test: Sinon.js

How test: Mocha+ChaiTest 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

or Jasmine

How test: Mocha+Chaior Jasmine

How test: Mocha+Chaior Jasmine

How test: Require.jsTest modular code

Clean state for each test

How test: Require.js