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
Better JavaScript with Jasmine
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Todd Kaufman
July 27, 2012
Technology
4
280
Better JavaScript with Jasmine
Quick introduction into the Jasmine testing framework for JavaScript, geared towards the rubyist.
Todd Kaufman
July 27, 2012
Tweet
Share
More Decks by Todd Kaufman
See All by Todd Kaufman
Under Pressure
toddkaufman
0
170
Becoming Less Horrible at Diversity
toddkaufman
1
150
Fallacies of Software Development
toddkaufman
0
140
Finding Joy at Work
toddkaufman
1
4.2k
Culture
toddkaufman
1
150
Enacting Change
toddkaufman
0
1.5k
Failing with Agility
toddkaufman
2
140
Agile Metrics
toddkaufman
4
960
Other Decks in Technology
See All in Technology
社内でAWS BuilderCards体験会を立ち上げ、得られた気づき / 20260225 Masaki Okuda
shift_evolve
PRO
1
150
AWS Bedrock Guardrails / 機密情報の入力・出力をブロックする — Blocking Sensitive Information Input/Output
kazuhitonakayama
2
180
ソフトウェアアーキテクトのための意思決定術: Create Decision Readiness—The Real Skill Behind Architectural Decision
snoozer05
PRO
26
7.4k
クラウド時代における一時権限取得
krrrr38
1
120
WBCの解説は生成AIにやらせよう - 生成AIで野球解説者AI Agentを実現する / Baseball Commentator AI Agent for Gemini
shinyorke
PRO
0
290
Devinを導入したら予想外の人たちに好評だった
tomuro
0
420
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
4k
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.1k
Interop Tokyo 2025 ShowNet Team Memberで学んだSRv6を基礎から丁寧に
miyukichi_ospf
0
220
LINEヤフーにおけるAI駆動開発組織のプロデュース施策
lycorptech_jp
PRO
0
180
Vertex AI Agent Engine で学ぶ「記憶」の設計
tkikuchi
0
110
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.4k
Featured
See All Featured
Color Theory Basics | Prateek | Gurzu
gurzu
0
220
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.3k
How Software Deployment tools have changed in the past 20 years
geshan
0
32k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
88
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
69
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
140
The Limits of Empathy - UXLibs8
cassininazir
1
240
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
220
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Done Done
chrislema
186
16k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Transcript
Better Javascript with Jasmine
I don’t test my JavaScript because ______________
“Semicolons are for losers”
“It can’t be automated”
“I already test it with Cucumber”
“I don’t have any REAL BUSINESS LOGIC in my JavaScript”
“It’s too hard”
“It changes too often”
“I’m lazy”
“It’s not worth the effort”
I have [ ] more [ ] less JavaScript in
my code than I used to.
I have [ X ] more [ ] less JavaScript
in my code than I used to.
None
Rubyists need not fear
the authors may have seen RSpec before
describe RomanNumeral do it "should convert I to 1" do
subject = RomanNumeral.new("I") subject.to_i.should eq(1) end end
describe("RomanNumeral", function() { it("returns 1 for I", function() { var
subject = new RomanNumeral("I"); return expect(subject.toI()).toBe(1); }); });
basics
RSpec Jasmine describe User do describe(“User”, function() it “saves stuff”
do it (“saves stuff”, function() value.should expect(value)
matchers
RSpec Jasmine name.should eq(“Todd”) expect(name).toBe(“Todd”); (3*3).should_not == 8 expect(3*3).not.toBe(8); be,
eql, equal, ==, === toEqual, toBe
None
None
RSpec Jasmine 7.should be_true expect(7).toBeTruthy(); (7).should_not be(true) expect(7).not.toBe(true); nil.should be_false
expect(null).toBeFalsy();
RSpec Jasmine [‘a’,’b’].should include(‘a’) expect([3,4]).toContain(4); (1.05).should be_close(1, 0.06) expect(1.05).toBeCloseTo(1, 0)
nil.should be_false expect(null).toBeFalsy();
toBeDefined / toBeUndefined toMatch(/regex/) toThrow custom matchers as well
beforeEach afterEach
xdescribe xit
None
test doubles
None
spies
None
None
None
None
None
None
None
None
stubs
None
jasmine-stealth
None
fakes
None
mocks
ease of use
None
None
None
but, semicolons are still for losers
describe("RomanNumeral", function() { it("returns 1 for I", function() { var
subject = new RomanNumeral("I"); return expect(subject.toI()).toBe(1); }); });
describe "RomanNumeral", -> it "returns 1 for I", -> subject
= new RomanNumeral("I") expect(subject.toI()).toBe 1
Great, so how do I run this stuff?
www.tryjasmine.com
None
Jasmine standalone
https://github.com/ pivotal/jasmine/ downloads
None
Jasmine within Rails
gem install jasmine
jasmine-headless-webkit
None
None
gem install jasmine-rails
Available for other enviroments as well
what now?
it’s not that hard
it is important
you have no excuses
Thanks! @toddkaufman @testdouble