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
Jasmine, BDD for JavaScript
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Chris Bushell
May 18, 2011
130
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Jasmine, BDD for JavaScript
Prepared for the Melbourne Patterns Group
Chris Bushell
May 18, 2011
More Decks by Chris Bushell
See All by Chris Bushell
Test Automation for Packaged Systems: Yes You Can!
cbushell
0
84
Introduction to Pair Programming
cbushell
1
140
An Introduction to BDD
cbushell
5
180
An Introduction to HTTP
cbushell
2
140
Agile Test Automation
cbushell
2
190
Working Effectively With Legacy Code
cbushell
4
260
Branches Are For Trees. How to Develop Software Without Them
cbushell
1
130
State Pattern From GoF
cbushell
1
78
Continuous Integration, fast builds and Flot
cbushell
2
84
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
260
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
180
Facilitating Awesome Meetings
lara
57
7k
Writing Fast Ruby
sferik
630
63k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
420
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.5k
Raft: Consensus for Rubyists
vanstee
141
7.6k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
340
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
40k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Transcript
BDD for JavaScript
A li1le history….
1995, Netscape, Mocha, LiveScript, JavaScript (aka ECMAScript)
None
1999, MicrosoD, XMLHTTPRequest
2004, GMail
2005, Jesse James Garret, Ajax: A New Approach to
Web ApplicaWons
None
2011, GitHub
Development has outpaced tesWng maturity
Why the tendency only to integraWon test our JavaScript?
An idea! Test driven JavaScript
Meet Jasmine…. and JsUnit and JsTestDriver
and Screw.Unit and JSMockito etc.
Why Jasmine? RSpec like syntax Super fast
Easy to integrate Runs anywhere JavaScript runs Supports tesWng of asynchronous code
So, show me….
Some extensions h1ps://github.com/mhevery/jasmine-‐node h1p://rudyla1ae.github.com/jasmine-‐species h1ps://github.com/pivotal/jasmine-‐ajax
Jasmine jQuery • Custom matchers • toHaveHtml(string)
• toBeHidden() • toBeSelected() • spyOnEvent($(‘#some element’), ‘click’) • An API for loading HTML fixtures • loadFixtures(‘myFixturesFile.html’);
Working with the DOM • DRY • Use
your applicaWon to generate the fixture data from actual views • Load the fixture using XHR • Example: h1ps://github.com/pivotaljb/js-‐ fixture-‐example
Watch out for…. • Syntax errors cause specs to
fail silently • Different browsers, different traces