Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

Why ADD? Because I change my mind about testing tools/frameworks every few days 2 also...

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

I always use Casper.js for acceptance testing 4

Slide 5

Slide 5 text

... or capybara

Slide 6

Slide 6 text

...or cucumber

Slide 7

Slide 7 text

Just be sure to use something 7

Slide 8

Slide 8 text

The use Konacha for everything else 8

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

Chai Assertions 10

Slide 11

Slide 11 text

Mocha 11

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

Basic Unit Test 13

Slide 14

Slide 14 text

Basic Unit Test 14

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

TDD an Ember View 16

Slide 17

Slide 17 text

TDD an Ember View 17

Slide 18

Slide 18 text

TDD an Ember View 18

Slide 19

Slide 19 text

Integration testing Verify that your App’s Models, Views, Controllers and Routes work together 19

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

21 Demo app based on Ember Play TODO’s. BTW check out emberplay.com

Slide 22

Slide 22 text

Integration Test Demo Konacha test runner JS Console access to test environment via iframe 22

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

questions? Mike Grassotti github: mikegrassotti twitter: @mgrassotti 24