Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Jasmine, BDD for JavaScript
Search
Chris Bushell
May 18, 2011
1
120
Jasmine, BDD for JavaScript
Prepared for the Melbourne Patterns Group
Chris Bushell
May 18, 2011
Tweet
Share
More Decks by Chris Bushell
See All by Chris Bushell
Test Automation for Packaged Systems: Yes You Can!
cbushell
0
63
Introduction to Pair Programming
cbushell
1
120
An Introduction to BDD
cbushell
5
170
An Introduction to HTTP
cbushell
2
130
Agile Test Automation
cbushell
2
180
Working Effectively With Legacy Code
cbushell
4
250
Branches Are For Trees. How to Develop Software Without Them
cbushell
1
110
State Pattern From GoF
cbushell
1
67
Continuous Integration, fast builds and Flot
cbushell
2
71
Featured
See All Featured
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
170
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
Why Our Code Smells
bkeepers
PRO
340
57k
Side Projects
sachag
455
43k
It's Worth the Effort
3n
187
29k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
110
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
Unsuck your backbone
ammeep
671
58k
Chasing Engaging Ingredients in Design
codingconduct
0
75
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
110
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