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
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
act1-costs.pdf
sumedhbala
0
110
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
930
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
590
Lessons from Spec-Driven Development
simas
PRO
0
220
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
920
スマートグラスで並列バイブコーディング
hyshu
0
260
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
160
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
320
A2UI という光を覗いてみる
satohjohn
1
150
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
130
技術記事、 専門家としてのプログラマ、 言語化
mizchi
13
6.5k
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
Rails Girls Zürich Keynote
gr2m
96
14k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
210
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
260
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
870
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
440
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
190
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Designing for Performance
lara
611
70k
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