$30 off During Our Annual Pro Sale. View Details »

An ADD approach to testing ember.js

An ADD approach to testing ember.js

Slides from November 2012 ember nyc meetup

Video of the presentation is here: http://bit.ly/WlvOhD

Michael Grassotti

November 29, 2012
Tweet

More Decks by Michael Grassotti

Other Decks in Technology

Transcript

  1. An ADD Approach to Testing Ember.js Emberjs NYC Meetup November

    2012 1
  2. Why ADD? Because I change my mind about testing tools/frameworks

    every few days 2 also...
  3. Acceptance Driven Development Focus on acceptance criteria, don’t write code

    you don’t need. Start with acceptance tests. Verify that your app works for happy-path use cases 3
  4. I always use Casper.js for acceptance testing 4

  5. ... or capybara

  6. ...or cucumber

  7. Just be sure to use something 7

  8. The use Konacha for everything else 8

  9. Konacha Konacha is a mocha/chai test runner for rails 3

    apps. Each spec is executed in an iframe runs in-browser or command-line 9
  10. Chai Assertions 10

  11. Mocha 11

  12. Unit testing Models, views, controllers and routes, tested in isolation

    12
  13. Basic Unit Test 13

  14. Basic Unit Test 14

  15. TDD an Ember View Example stolen from: http:/ /shairez.com/2012/07/ember-js-tdd-how-to-test-your-ember-views/ 15

  16. TDD an Ember View 16

  17. TDD an Ember View 17

  18. TDD an Ember View 18

  19. Integration testing Verify that your App’s Models, Views, Controllers and

    Routes work together 19
  20. How? Boot instance of app Load test data Use App.router.route(‘/’)

    to navigate Maybe submit a form or two Verify output, like $(‘#id’).text() 20
  21. 21 Demo app based on Ember Play TODO’s. BTW check

    out emberplay.com
  22. Integration Test Demo Konacha test runner JS Console access to

    test environment via iframe 22
  23. App.reset() ? Would be nice, not gonna happen anytime soon.

    Roll your own involves: reset state of controllers rollback injections clear dom god-knows what else. Hard since Ember is a moving target... So without reset(), how do we prevents specs from having side effects? Run each integration test in isolated environment (iframe) via konacha test runner 23
  24. questions? Mike Grassotti github: mikegrassotti twitter: @mgrassotti 24