Top Banner
Just Test It Karma, Mocha, Sinon.js Artyom Trityak
16
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Just Test It

Just Test ItKarma, Mocha, Sinon.js

Artyom Trityak

Page 2: Just Test It

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!

Page 3: Just Test It

What test?Business logic

Page 4: Just Test It

What test?Business logic where? Models

ControllersViews

Page 5: Just Test It

What test?Business logic

Models

Controllers

Page 6: Just Test It

What test?Business logic

Models

Controllers

Shared functionality (base classes, utils etc)

Page 7: Just Test It

How test: KarmaRuns your unittests in different browsers automatically: Chrome, Phantomjs, Firefox, Safari, IE

Run-on-change

Test in real devices: phones, tablets etc

Page 8: Just Test It

How test: Karma

Page 9: Just Test It

How test: Sinon.jsMock modules dependencies

Mock backend requests and responses

Mock / stub methods and objects

Check methods calledWith and callCount

Page 10: Just Test It

How test: Sinon.js

Page 11: Just Test It

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

Page 12: Just Test It

How test: Mocha+Chaior Jasmine

Page 13: Just Test It

How test: Mocha+Chaior Jasmine

Page 14: Just Test It

How test: Require.jsTest modular code

Clean state for each test

Page 15: Just Test It

How test: Require.js

Page 16: Just Test It