Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Front-End UnitTesting

1,008 views

Published on

How to write unittests, launch multiple browsers and mock data

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

Front-End UnitTesting

  1. 1. Артем Тритяк Unittesting frontend applications at Backbone.js example
  2. 2. Why? ❖ Regressions testing is too long! ❖ Short sprints issues! ❖ Dangerous refactoring! ❖ Test API usability! ❖ Отличная отмаза: «Что делаете? Пишем тесты!»
  3. 3. What test? Business logic Public API
  4. 4. What test? Business logic Public API Model! (Service) Collection Controller
  5. 5. What test? Shared functionality Mixins Base! views, controllers, models Helpers
  6. 6. Clean your karma
  7. 7. Karma Test Runner
  8. 8. Karma Test Runner
  9. 9. Karma Test Runner
  10. 10. Karma Test Runner
  11. 11. Runners: Grunt
  12. 12. Runners: Gulp
  13. 13. Istanbul: Code Coverage
  14. 14. Istanbul Karma Gulp
  15. 15. Istanbul: Code Coverage
  16. 16. Karma + Require.js
  17. 17. Karma + Require.js
  18. 18. Jasmine 2.0 / Mocha+Chai
  19. 19. beforeEach / afterEach
  20. 20. Async tests
  21. 21. Sinon.js: Mock XHR
  22. 22. Sinon.js: Stub methods
  23. 23. Sinon.js: Fake and Test ❖ Fake timers: sinon.useFakeTimers();! ❖ Check calls: spy, .calledWith(…), .callCount() etc;! ❖ Have fun
  24. 24. Backbone.Model
  25. 25. Backbone.Collection
  26. 26. Backbone.Collection
  27. 27. Backbone.Controller
  28. 28. Backbone.Controller? WTF? ❖ https://github.com/artyomtrityak/backbone.controller! ❖ Backbone.Marionette controller! ❖ Backbone.Chaplin controller
  29. 29. Backbone.View No tests

×