Slide 1

Slide 1 text

Ember Testing Guide The Unofficial #emberconf

Slide 2

Slide 2 text

I tweet at @cavneb @coderberry I blog at coderberry.me I commit to github.com/cavneb I work for Instructure I run the EmberSLC meetup My cat can eat a whole watermelon Eric Berry

Slide 3

Slide 3 text

@_mmun @codeofficer @mixonic @jgwhite @isaacezer @kkrajcev @JimDAlbano @bantic @terzicigor @blairbodnar @twukol @joefiorini @abuiles @workmanw @bezomaxo

Slide 4

Slide 4 text

"SJSA Grade Six - The Year I Rebelled" by Michael 1952 BE GOOD

Slide 5

Slide 5 text

"SJSA Grade Six - The Year I Rebelled" by Michael 1952 attrib: inspiredMonkey.com

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Ember Testing

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Happy Birthday

Slide 10

Slide 10 text

How to Test

Slide 11

Slide 11 text

Assertions

Slide 12

Slide 12 text

qunit

Slide 13

Slide 13 text

jsbin.com/suteg 1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11! 12! 13 module('group of tests', {! setup: function() {! // run before each test! },! teardown: function() {! // run after each test! }! });! ! test('should be true', function() {! ok(true, 'should be true');! equal(1, 1, 'should equal');! });

Slide 14

Slide 14 text

qunit-basics.js 1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11! 12! 13 module('group of tests', {! setup: function() {! // run before each test! },! teardown: function() {! // run after each test! }! });! ! test('should be true', function() {! ok(true, 'should be true');! equal(1, 1, 'should equal');! }); callbacks

Slide 15

Slide 15 text

assertion inverse assertion equal() notEqual() deepEqual() notDeepEqual() propEqual() notPropEqual() strictEqual() notStrictEqual() ok() throws() http://api.qunitjs.com/category/assert/

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

“We're paving the QUnit happy path but not excluding others.”

Slide 19

Slide 19 text

Happy Path!

Slide 20

Slide 20 text

Assertions

Slide 21

Slide 21 text

Helpers

Slide 22

Slide 22 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11 App.setupForTesting();! App.injectTestHelpers();! ! test(‘welcome page', function() {! visit('/');! ! andThen(function() {! equal(find('h2').text(), 'Welcome to Ember.js');! equal(find('ul li').length, 3);! });! }); jsbin.com/suteg

Slide 23

Slide 23 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11 App.setupForTesting();! App.injectTestHelpers();! ! test(‘welcome page', function() {! visit('/');! ! andThen(function() {! equal(find('h2').text(), 'Welcome to Ember.js');! equal(find('ul li').length, 3);! });! }); jsbin.com/suteg

Slide 24

Slide 24 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11 App.setupForTesting();! App.injectTestHelpers();! ! test(‘welcome page', function() {! visit('/');! ! andThen(function() {! equal(find('h2').text(), 'Welcome to Ember.js');! equal(find('ul li').length, 3);! });! }); jsbin.com/suteg

Slide 25

Slide 25 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11 App.setupForTesting();! App.injectTestHelpers();! ! test(‘welcome page', function() {! visit('/');! ! andThen(function() {! equal(find('h2').text(), 'Welcome to Ember.js');! equal(find('ul li').length, 3);! });! }); jsbin.com/suteg

Slide 26

Slide 26 text

Ember.Test provides QUnit provides

Slide 27

Slide 27 text

Ember Testing

Slide 28

Slide 28 text

visit() fillIn() click() andThen() find() keyEvent()

Slide 29

Slide 29 text

asynchronous visit() fillIn() click() andThen() find() keyEvent()

Slide 30

Slide 30 text

synchronous visit() fillIn() click() andThen() find() keyEvent()

Slide 31

Slide 31 text

wait helper visit() fillIn() click() andThen() find() keyEvent()

Slide 32

Slide 32 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10 test('add new post', function() {! visit('/posts/new');! fillIn('input.title', 'My new post');! click('button.submit');! ! andThen(function() {! equal(find('ul.posts li:last').text(), ! 'My new post');! });! }); jsbin.com/vusaz visit() fillIn() click() andThen() find() keyEvent()

Slide 33

Slide 33 text

visit() fillIn() click() andThen() find() keyEvent() 1! 2! 3! 4! 5! 6! 7! 8! 9! 10 test('add new post', function() {! visit('/posts/new');! fillIn('input.title', 'My new post');! click('button.submit');! ! andThen(function() {! equal(find('ul.posts li:last').text(), ! 'My new post');! });! }); jsbin.com/vusaz

Slide 34

Slide 34 text

visit() fillIn() click() andThen() find() keyEvent() 1! 2! 3! 4! 5! 6! 7! 8! 9! 10 test('add new post', function() {! visit('/posts/new');! fillIn('input.title', 'My new post');! click('button.submit');! ! andThen(function() {! equal(find('ul.posts li:last').text(), ! 'My new post');! });! }); jsbin.com/vusaz

Slide 35

Slide 35 text

visit() fillIn() click() andThen() find() keyEvent() 1! 2! 3! 4! 5! 6! 7! 8! 9! 10 test('add new post', function() {! visit('/posts/new');! fillIn('input.title', 'My new post');! click('button.submit');! ! andThen(function() {! equal(find('ul.posts li:last').text(), ! 'My new post');! });! }); jsbin.com/vusaz

Slide 36

Slide 36 text

visit() fillIn() click() andThen() find() keyEvent() 1! 2! 3! 4! 5! 6! 7! 8! 9! 10 test('add new post', function() {! visit('/posts/new');! fillIn('input.title', 'My new post');! click('button.submit');! ! andThen(function() {! equal(find('ul.posts li:last').text(), ! 'My new post');! });! }); jsbin.com/vusaz

Slide 37

Slide 37 text

visit() fillIn() click() andThen() find() keyEvent() 1! 2! 3! 4! 5! 6! 7! 8! 9! 10 test('add new post', function() {! visit('/posts/new');! fillIn('input.title', 'My new post');! click('button.submit');! ! andThen(function() {! equal(find('ul.posts li:last').text(), ! 'My new post');! });! }); jsbin.com/vusaz

Slide 38

Slide 38 text

TEAMWORK! TEAMWORK!

Slide 39

Slide 39 text

Custom Helpers

Slide 40

Slide 40 text

registerHelper(name, func, [options]) 1! 2! 3! 4! 5! 6! 7! 8! 9! 10 Ember.Test.registerHelper('currentURL', ! function(app) {! return app.__container__.lookup('router:main')! .get('location')! .getURL()! }! );! ! // runs instantly! equal(currentUrl(), '/posts/new');

Slide 41

Slide 41 text

registerAsyncHelper(name, func, [options]) 1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11 Ember.Test.registerAsyncHelper('submitForm',! function(app, selector, context) {! var $el = findWithAssert(selector, context);! Ember.run(function() {! $el.submit();! });! }! );! ! // usage! submitForm('.my-form');!

Slide 42

Slide 42 text

INJECT REMEMBER TO App.injectTestHelpers(); CUSTOM HELPERS

Slide 43

Slide 43 text

is that it?

Slide 44

Slide 44 text

Ember 1.5

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

More
 Helpers

Slide 47

Slide 47 text

triggerEvent() currentRouteName() currentPath() currentURL() Integration THE NEXT GENERATION Helpers

Slide 48

Slide 48 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11! 12 test('trigger events', function() {! ! // simulate enter key! triggerEvent('#name', 'keypress', { keyCode: 13 });! ! // blur element! triggerEvent('#search', 'blur');! ! // double-click element! triggerEvent('.post-5', 'dblclick');
 ! });! ! triggerEvent(selector, type, [options])

Slide 49

Slide 49 text

1! 2! 3! 4! 5! 6! 7! 8! 9 test('root path goes to posts.index', function() {! visit('/');! andThen(function() {! ! // assert we made it to the correct route! equal(currentRouteName(), 'posts.index');! ! });! });! currentRouteName() App.__container__.lookup(‘controllers:application’).get(’currentRouteName’)

Slide 50

Slide 50 text

1! 2! 3! 4! 5! 6! 7! 8! 9 test('redirect occurred', function() {! visit('/posts/new');! andThen(function() {! ! // assert we made it to the correct route! equal(currentPath(), 'posts.new');! ! });! });! currentPath() App.__container__.lookup(‘controllers:application’).get(’currentPath’)

Slide 51

Slide 51 text

1! 2! 3! 4! 5! 6! 7! 8! 9 test('redirect occurred', function() {! visit('/posts/new');! andThen(function() {! ! // assert we made it to the correct route! equal(currentURL(), '/posts/new');! ! });! });! currentURL() App.__container__.lookup(‘router:main’).get(’location’).getURL()

Slide 52

Slide 52 text

Who are you tryin' to get crazy with, ese? Don't you know we need more???

Slide 53

Slide 53 text

“integration tests prove 
 your communication, unit tests prove your code” - Julian Simioni (@juliansimioni)

Slide 54

Slide 54 text

“integration tests prove 
 your communication, unit tests prove your code” - Julian Simioni (@juliansimioni)

Slide 55

Slide 55 text

Scenario 1: A list of posts should be filterable by title Given there are 3 posts When I visit ‘/posts’ And enter filter text which matches 1 post Then I should see 1 post

Slide 56

Slide 56 text

BDD

Slide 57

Slide 57 text

integration

Slide 58

Slide 58 text

Scenario 1: A list of posts should be filterable by title Given there are 3 posts When I visit ‘/posts’ And enter filter text which matches 1 post Then I should see 1 post

Slide 59

Slide 59 text

jsbin.com/cahuc 1! 2! 3! 4! 5! 6! 7 test("filters posts by title", function() {! visit("/posts");! fillIn(".search", "auth");! andThen(function() {! equal(find(".post-title").length, 1);! })! });!

Slide 60

Slide 60 text

jsbin.com/cahuc 1! 2! 3! 4! 5! 6! 7 test("filters posts by title", function() {! visit("/posts");! fillIn(".search", "auth");! andThen(function() {! equal(find(".post-title").length, 1);! })! });! 1! 2! 3! 4! 5! 6! 7 test("filters users by name", function() {! visit("/users");! fillIn(".search", “Bob Hanson");! andThen(function() {! equal(find(".user-name").length, 1);! })! });!

Slide 61

Slide 61 text

1! 2! 3! 4! 5 App.PostsController = Ember.ArrayController.extend(! App.FilterableArrayMixin, {! ! filterField: 'title'! });! 1! 2! 3! 4! 5 App.UsersController = Ember.ArrayController.extend(! App.FilterableArrayMixin, {! ! filterField: 'name'! });! jsbin.com/cahuc

Slide 62

Slide 62 text

1! 2! 3! 4! 5 App.PostsController = Ember.ArrayController.extend(! App.FilterableArrayMixin, {! ! filterField: 'title'! });! 1! 2! 3! 4! 5 App.UsersController = Ember.ArrayController.extend(! App.FilterableArrayMixin, {! ! filterField: 'name'! });! jsbin.com/cahuc

Slide 63

Slide 63 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11! 12! 13! 14! 15 App.FilterableArrayMixin = Ember.Mixin.create({! filterText: null,! ! filteredContent: function() {! var filterText = this.getWithDefault('filterText', '');! if (Em.isEmpty(filterText)) {! return this.get('content');! } else {! return this.get('content').filter(function(item) {! var str = item.get(this.get('filterField')).toLowerCase();! return str.match(filterText.toLowerCase());! }.bind(this));! }! }.property('content', 'filterText')! });! jsbin.com/cahuc

Slide 64

Slide 64 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11! 12! 13! 14! 15 App.FilterableArrayMixin = Ember.Mixin.create({! filterText: null,! ! filteredContent: function() {! var filterText = this.getWithDefault('filterText', '');! if (Em.isEmpty(filterText)) {! return this.get('content');! } else {! return this.get('content').filter(function(item) {! var str = item.get(this.get('filterField')).toLowerCase();! return str.match(filterText.toLowerCase());! }.bind(this));! }! }.property('content', 'filterText')! });! jsbin.com/cahuc

Slide 65

Slide 65 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11! 12! 13! 14! 15 App.FilterableArrayMixin = Ember.Mixin.create({! filterText: null,! ! filteredContent: function() {! var filterText = this.getWithDefault('filterText', '');! if (Em.isEmpty(filterText)) {! return this.get('content');! } else {! return this.get('content').filter(function(item) {! var str = item.get(this.get('filterField')).toLowerCase();! return str.match(filterText.toLowerCase());! }.bind(this));! }! }.property('content', 'filterText')! });! ISOLATED? jsbin.com/cahuc

Slide 66

Slide 66 text

unit

Slide 67

Slide 67 text

“integration tests prove 
 your communication, unit tests prove your code” - Julian Simioni (@juliansimioni)

Slide 68

Slide 68 text

IT’S NOT FUN

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

Templates Views Controllers Routes Models Core

Slide 71

Slide 71 text

Container

Slide 72

Slide 72 text

RESOLVER THE

Slide 73

Slide 73 text

Test

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

Ember-QUnit github.com/rpflorence/ember-qunit

Slide 77

Slide 77 text

no more everything

Slide 78

Slide 78 text

inspired by rspec

Slide 79

Slide 79 text

packaged for CommonJS AMD Named AMD Globals

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

setup

Slide 82

Slide 82 text

globals-unit-test-setup.js 1! 2! 3! 4! 5! 6! 7! 8 // inject test helpers onto window! emq.globalize();! ! // create a custom test resolver! App.Resolver = Ember.DefaultResolver.extend({ namespace: App });! ! // set the test resolver! setResolver(App.Resolver.create());! Globals

Slide 83

Slide 83 text

globals-unit-test-setup.js 1! 2! 3! 4! 5! 6! 7! 8 // inject test helpers onto window! emq.globalize();! ! // create a custom test resolver! App.Resolver = Ember.DefaultResolver.extend({ namespace: App });! ! // set the test resolver! setResolver(App.Resolver.create());! Globals

Slide 84

Slide 84 text

globals-unit-test-setup.js 1! 2! 3! 4! 5! 6! 7! 8 // inject test helpers onto window! emq.globalize();! ! // create a custom test resolver! App.Resolver = Ember.DefaultResolver.extend({ namespace: App });! ! // set the test resolver! setResolver(App.Resolver.create());! Globals

Slide 85

Slide 85 text

modules-unit-test-setup.js 1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11 // inject test helpers onto window! emq.globalize();! ! // import the existing resolver! import Resolver from ‘./path/to/resolver';! ! // import the setResolver function! import { setResolver } from ‘ember-qunit';! ! // set the resolver! setResolver(Resolver.create());! Modules

Slide 86

Slide 86 text

modules-unit-test-setup.js 1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11 // inject test helpers onto window! emq.globalize();! ! // import the existing resolver! import Resolver from ‘./path/to/resolver';! ! // import the setResolver function! import { setResolver } from ‘ember-qunit';! ! // set the resolver! setResolver(Resolver.create());! Modules

Slide 87

Slide 87 text

moduleFor() moduleForComponent() moduleForModel() Ember-QUnit

Slide 88

Slide 88 text

moduleFor(“route:index”)

Slide 89

Slide 89 text

moduleFor(“route:index”)

Slide 90

Slide 90 text

moduleFor(“route:index”)

Slide 91

Slide 91 text

Container moduleFor(“route:index”)

Slide 92

Slide 92 text

moduleFor(“route:index”) Container

Slide 93

Slide 93 text

Container test(‘test 1’, function() {! var route = this.subject();! }) test(‘test 1’, function() {! var route = this.subject();! }) moduleFor(“route:index”)

Slide 94

Slide 94 text

Container test(‘test 1’, function() {! var route = this.subject();! }) test(‘test 1’, function() {! var route = this.subject();! }) moduleFor(“route:index”)

Slide 95

Slide 95 text

moduleFor(fullName [, description [, callbacks]]) The description of the module description The full name of the unit (ie. controller:application or route:index) fullName Normal QUnit callbacks (setup, teardown), width addition of needs callbacks

Slide 96

Slide 96 text

routes

Slide 97

Slide 97 text

1! 2! 3! 4! 5! App.IndexRoute = Ember.Route.extend({! model: function() {! return ['red', 'green', 'blue'];! }! });! 1! 2! 3! 4! 5! 6 moduleFor('route:index', 'Unit: Index Route');! ! test('model', function() {! var route = this.subject();! equal(route.model().toString(), 'red,green,blue');! });! jsbin.com/qifon

Slide 98

Slide 98 text

1! 2! 3! 4! 5! App.IndexRoute = Ember.Route.extend({! model: function() {! return ['red', 'green', 'blue'];! }! });! 1! 2! 3! 4! 5! 6 moduleFor('route:index', 'Unit: Index Route');! ! test('model', function() {! var route = this.subject();! equal(route.model().toString(), 'red,green,blue');! });! jsbin.com/qifon

Slide 99

Slide 99 text

1! 2! 3! 4! 5! App.IndexRoute = Ember.Route.extend({! model: function() {! return ['red', 'green', 'blue'];! }! });! 1! 2! 3! 4! 5! 6! moduleFor('route:index', 'Unit: Index Route');! ! test('model', function() {! var route = this.subject();! equal(route.model().toString(), 'red,green,blue');! });! jsbin.com/qifon

Slide 100

Slide 100 text

1! 2! 3! 4! 5! App.IndexRoute = Ember.Route.extend({! model: function() {! return ['red', 'green', 'blue'];! }! });! 1! 2! 3! 4! 5! 6 moduleFor('route:index', 'Unit: Index Route');! ! test('model', function() {! var route = this.subject();! equal(route.model().toString(), 'red,green,blue');! });! jsbin.com/qifon

Slide 101

Slide 101 text

controllers

Slide 102

Slide 102 text

1! 2! 3! 4! 5! 6! 7! 8! ! 1! 2! 3! 4! 5! 6! 7! ! App.ApplicationController = Ember.Controller.extend({! user: null,! ! init: function() {! this._super.apply(this, arguments);! this.set('user', Em.Object.create({ name: 'Guest' }));! }! });! ! App.ProfileController = Ember.Controller.extend({! needs: ['application'],! ! name: function() {! return this.get('controllers.application.user.name');! }.property('controllers.application.user.name')! });! jsbin.com/numof

Slide 103

Slide 103 text

1! 2! 3! 4! 5! 6! 7! 8! ! 1! 2! 3! 4! 5! 6! 7! ! App.ApplicationController = Ember.Controller.extend({! user: null,! ! init: function() {! this._super.apply(this, arguments);! this.set('user', Em.Object.create({ name: 'Guest' }));! }! });! ! App.ProfileController = Ember.Controller.extend({! needs: ['application'],! ! name: function() {! return this.get('controllers.application.user.name');! }.property('controllers.application.user.name')! });! jsbin.com/numof

Slide 104

Slide 104 text

1! 2! 3! 4! 5! 6! 7! 8! 9 ! 10! 11! 12! 13! 14! ! moduleFor('controller:profile', 'Unit: Stuff Controller', {! needs: ['controller:application']! });! ! test('name', function() {! var ctrl = this.subject(),! appCtrl = ctrl.get('controllers.application');! ! equal(ctrl.get('name'), 'Guest');! Ember.run(function() {! appCtrl.get('user').set('name', 'Eric');! });! equal(ctrl.get('name'), 'Eric');! });! jsbin.com/numof

Slide 105

Slide 105 text

1! 2! 3! 4! 5! 6! 7! 8! 9 ! 10! 11! 12! 13! 14! ! moduleFor('controller:profile', 'Unit: Stuff Controller', {! needs: ['controller:application']! });! ! test('name', function() {! var ctrl = this.subject(),! appCtrl = ctrl.get('controllers.application');! ! equal(ctrl.get('name'), 'Guest');! Ember.run(function() {! appCtrl.get('user').set('name', 'Eric');! });! equal(ctrl.get('name'), 'Eric');! });! jsbin.com/numof

Slide 106

Slide 106 text

1! 2! 3! 4! 5! 6! 7! 8! 9 ! 10! 11! 12! 13! 14! ! moduleFor('controller:stuff', 'Unit: Stuff Controller', {! needs: ['controller:application']! });! ! test('name', function() {! var ctrl = this.subject(),! appCtrl = ctrl.get('controllers.application');! ! equal(ctrl.get('name'), 'Guest');! Ember.run(function() {! appCtrl.get('user').set('name', 'Eric');! });! equal(ctrl.get('name'), 'Eric');! });! jsbin.com/numof

Slide 107

Slide 107 text

1! 2! 3! 4! 5! 6! 7! 8! 9 ! 10! 11! 12! 13! 14! ! moduleFor('controller:stuff', 'Unit: Stuff Controller', {! needs: ['controller:application']! });! ! test('name', function() {! var ctrl = this.subject(),! appCtrl = ctrl.get('controllers.application');! ! equal(ctrl.get('name'), 'Guest');! Ember.run(function() {! appCtrl.get('user').set('name', 'Eric');! });! equal(ctrl.get('name'), 'Eric');! });! jsbin.com/numof

Slide 108

Slide 108 text

The description of the module description The short name of the component (ie. x-foo or ic-tabs) name Normal QUnit callbacks (setup, teardown), width addition of needs callbacks moduleForComponent(name [, description [, callbacks]])

Slide 109

Slide 109 text

1! 2! 3! 4! 5! 6! 7! App.PrettyColorComponent = Ember.Component.extend({! classNames: ['pretty-color'],! attributeBindings: ['style'],! style: function() {! return 'color: ' + this.get('color') + ';';! }.property('color')! });! jsbin.com/witut

Slide 110

Slide 110 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11! 12! …! moduleForComponent('pretty-color', 'Unit: components/pretty-color');! ! test("set colors", function() {! var component = this.subject();! ! Ember.run(function() {! component.set('color', 'green');! });! ! // first call to this.$() renders the component! equal(this.$().attr('style'), 'color: green;');! }); jsbin.com/witut

Slide 111

Slide 111 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11! 12! …! moduleForComponent('pretty-color', 'Unit: components/pretty-color');! ! test("set colors", function() {! var component = this.subject();! ! Ember.run(function() {! component.set('color', 'green');! });! ! // first call to this.$() renders the component! equal(this.$().attr('style'), 'color: green;');! }); jsbin.com/witut

Slide 112

Slide 112 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11! 12! …! moduleForComponent('pretty-color', 'Unit: components/pretty-color');! ! test("set colors", function() {! var component = this.subject();! ! Ember.run(function() {! component.set('color', 'green');! });! ! // first call to this.$() renders the component! equal(this.$().attr('style'), 'color: green;');! }); jsbin.com/witut

Slide 113

Slide 113 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11! 12! …! moduleForComponent('pretty-color', 'Unit: components/pretty-color');! ! test("set colors", function() {! var component = this.subject();! ! Ember.run(function() {! component.set('color', 'green');! });! ! // first call to this.$() renders the component! equal(this.$().attr('style'), 'color: green;');! }); jsbin.com/witut

Slide 114

Slide 114 text

jsbin.com/kilej

Slide 115

Slide 115 text

The description of the module description The short name of the model you’d use in `store` operations (ie. user or assignmentGroup) name Normal QUnit callbacks (setup, teardown), width addition of needs callbacks moduleForModel(name [, description [, callbacks]])

Slide 116

Slide 116 text

1! 2! 3! 4! 5! 6! 7! 8 App.User = DS.Model.extend({! fName: DS.attr('string'),! lName: DS.attr('string'),! verified: DS.attr('boolean', { defaultValue: false }),! createdAt: DS.attr('string', {! defaultValue: function() { return new Date(); }! })! }); jsbin.com/mapuf

Slide 117

Slide 117 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11 moduleForModel('user', 'Unit: User Model');! ! test('createdAt defaults to now', function() {! var user = this.subject({! firstName: 'Eric',! lastName: 'Berry'! });! var createdAt = user.get('createdAt');! var now = new Date();! equal(createdAt.toString(), now.toString());! });! jsbin.com/mapuf

Slide 118

Slide 118 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11 moduleForModel('user', 'Unit: User Model');! ! test('createdAt defaults to now', function() {! var user = this.subject({! firstName: 'Eric',! lastName: 'Berry'! });! var createdAt = user.get('createdAt');! var now = new Date();! equal(createdAt.toString(), now.toString());! });! jsbin.com/mapuf

Slide 119

Slide 119 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11 moduleForModel('user', 'Unit: User Model');! ! test('createdAt defaults to now', function() {! var user = this.subject({! firstName: 'Eric',! lastName: 'Berry'! });! var createdAt = user.get('createdAt');! var now = new Date();! equal(createdAt.toString(), now.toString());! });! jsbin.com/mapuf

Slide 120

Slide 120 text

1! 2! 3! 4! 5! 6! 7! 8! 9! 10! 11 moduleForModel('user', 'Unit: User Model');! ! test('createdAt defaults to now', function() {! var user = this.subject({! firstName: 'Eric',! lastName: 'Berry'! });! var createdAt = user.get('createdAt');! var now = new Date();! equal(createdAt.toString(), now.toString());! });! jsbin.com/mapuf

Slide 121

Slide 121 text

github/rpflorence/ember-qunit

Slide 122

Slide 122 text

bower install ember-qunit

Slide 123

Slide 123 text

already included in
 ember-app-kit

Slide 124

Slide 124 text

already included in
 ember-cli

Slide 125

Slide 125 text

and…

Slide 126

Slide 126 text

Almost done… http://goo.gl/ov6SSb

Slide 127

Slide 127 text

thank you @rwjblue @stefanpenner @abuiles @dericabel @tehviking @ryanflorence @fivetanley @jason.madsen @sterlingcobb @codeofficer @JimDAlvado @ryankshaw @DevEngine @toranb

Slide 128

Slide 128 text

thank you spouses, partners and 
 significant others

Slide 129

Slide 129 text

I tweet at @coderberry I blog at coderberry.me I commit to github.com/cavneb I work for Instructure I run the EmberSLC meetup I actually don’t even have a cat Questions?