Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
testing-ember-apps.pdf
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Tom Kruijsen
March 12, 2014
Programming
77
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
testing-ember-apps.pdf
Tom Kruijsen
March 12, 2014
More Decks by Tom Kruijsen
See All by Tom Kruijsen
Functional Reactive Programming in Bacon.js
tomkr
2
120
To Framework or not to Framework
tomkr
0
83
Functional Reactive Programming with BaconJS
tomkr
0
77
Philosophy for Web Developers
tomkr
0
68
An Introduction to Leaflet
tomkr
0
100
Ember on Rails
tomkr
4
180
Other Decks in Programming
See All in Programming
AI 輔助遺留系統現代化的經驗分享
jame2408
1
980
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
210
A2UI という光を覗いてみる
satohjohn
1
150
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
1
240
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
180
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
120
OSもどきOS
arkw
0
590
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
160
New "Type" system on PicoRuby
pocke
1
1k
Oxcを導入して開発体験が向上した話
yug1224
4
340
技術記事、 専門家としてのプログラマ、 言語化
mizchi
13
6.5k
JavaDoc 再入門
nagise
1
410
Featured
See All Featured
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
200
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Statistics for Hackers
jakevdp
799
230k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
440
Skip the Path - Find Your Career Trail
mkilby
1
150
Practical Orchestrator
shlominoach
191
11k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
400
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Transcript
Testing Ember Apps Tom Kruijsen Ember.js - 2014-03-12
Brightin
None
Warning: blatant self- promotion
Appuccino
Some questions
Integration tests with QUnit
Unit tests?
Why QUnit?
None
Konacha
Rails gem
Mocha & Chai
None
#= require 'sinon'! #= require 'application'! ! mocha.ui('bdd')! mocha.globals(['Ember', 'DS',
'Catstagram', 'MD5'])! mocha.timeout(5)! chai.Assertion.includeStack = true! ! ENV = {! TESTING: true! }! ! window.server = sinon.fakeServer.create()! ! window.testHelper =! lookup: (object, object_name) ->! name = object_name || "main"! Catstagram.__container__.lookup(object + ":" + name)! ! Catstagram.Router.reopen! location: 'none'! ! Konacha.reset = Ember.K! ! Catstagram.setupForTesting()! Catstagram.injectTestHelpers()! ! beforeEach ->! Ember.run ->! Catstagram.reset()! ! Ember.Test.adapter = Ember.Test.Adapter.create()
#= require spec_helper! ! describe "Cat", ->! it "is a
DS.Model", ->! expect(Catstagram.Cat).to.exist! expect(DS.Model.detect(Catstagram.Cat)).to.exist! ! it "has a name", =>! Ember.run( ->! cat = testHelper.lookup('store').createRecord 'cat', name: 'Mimi'! expect(cat.get 'name').to.equal 'Mimi'! )
#= require 'spec_helper'! ! describe 'Cats page', ->! beforeEach ->!
cat = Ember.Object.create! id: 1! name: 'Mimi'! ! stubStore = sinon.stub(testHelper.lookup('store'), 'find')! stubStore.withArgs('cat').returns([cat])! ! ! visit '/'! ! it 'shows the names of the cats', ->! expect($('li').text()).to.equal('Mimi')! ! it 'links to a cat page', ->! mock = sinon.mock(testHelper.lookup('route', 'cats_cat'))! mock.expects('setupController').once()! $('a').click()! mock.verify()
Mocha is nicer than QUnit
Use Sinon and mock a lot
How do you test your apps?
Testing Ember Apps Tom Kruijsen Ember.js - 2014-03-12