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
Chris Bushell
May 18, 2011
1
110
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
49
Introduction to Pair Programming
cbushell
1
100
An Introduction to BDD
cbushell
5
160
An Introduction to HTTP
cbushell
2
120
Agile Test Automation
cbushell
2
170
Working Effectively With Legacy Code
cbushell
4
240
Branches Are For Trees. How to Develop Software Without Them
cbushell
1
91
State Pattern From GoF
cbushell
1
55
Continuous Integration, fast builds and Flot
cbushell
2
54
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
331
56k
The Mythical Team-Month
searls
216
42k
Testing 201, or: Great Expectations
jmmastey
30
6.4k
10 Git Anti Patterns You Should be Aware of
lemiorhan
649
58k
Thoughts on Productivity
jonyablonski
60
3.9k
BBQ
matthewcrist
80
8.8k
Designing on Purpose - Digital PM Summit 2013
jponch
111
6.5k
Designing with Data
zakiwarfel
96
4.8k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
358
22k
Embracing the Ebb and Flow
colly
80
4.2k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
155
14k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.1k
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