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
Todd Kaufman
July 27, 2012
Technology
4
250
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
140
Becoming Less Horrible at Diversity
toddkaufman
1
130
Fallacies of Software Development
toddkaufman
0
120
Finding Joy at Work
toddkaufman
1
4.2k
Culture
toddkaufman
1
130
Enacting Change
toddkaufman
0
1.4k
Failing with Agility
toddkaufman
2
120
Agile Metrics
toddkaufman
4
920
Other Decks in Technology
See All in Technology
初めてのAzure FunctionsをClaude Codeで作ってみた / My first Azure Functions using Claude Code
hideakiaoyagi
1
210
Prox Industries株式会社 会社紹介資料
proxindustries
0
270
A2Aのクライアントを自作する
rynsuke
1
170
ひとり情シスなCTOがLLMと始めるオペレーション最適化 / CTO's LLM-Powered Ops
yamitzky
0
420
TechLION vol.41~MySQLユーザ会のほうから来ました / techlion41_mysql
sakaik
0
180
AIエージェント最前線! Amazon Bedrock、Amazon Q、そしてMCPを使いこなそう
minorun365
PRO
13
4.9k
Understanding_Thread_Tuning_for_Inference_Servers_of_Deep_Models.pdf
lycorptech_jp
PRO
0
110
Snowflake Summit 2025 データエンジニアリング関連新機能紹介 / Snowflake Summit 2025 What's New about Data Engineering
tiltmax3
0
300
GitHub Copilot の概要
tomokusaba
1
130
AWS Summit Japan 2025 Community Stage - App workflow automation by AWS Step Functions
matsuihidetoshi
1
240
BrainPadプログラミングコンテスト記念LT会2025_社内イベント&問題解説
brainpadpr
1
160
製造業からパッケージ製品まで、あらゆる領域をカバー!生成AIを利用したテストシナリオ生成 / 20250627 Suguru Ishii
shift_evolve
PRO
1
130
Featured
See All Featured
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
124
52k
Making Projects Easy
brettharned
116
6.3k
Designing Experiences People Love
moore
142
24k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
Rebuilding a faster, lazier Slack
samanthasiow
81
9.1k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
Building Applications with DynamoDB
mza
95
6.5k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
How GitHub (no longer) Works
holman
314
140k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3k
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