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
140
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
88
Introduction to Pair Programming
cbushell
1
140
An Introduction to BDD
cbushell
5
190
An Introduction to HTTP
cbushell
2
150
Agile Test Automation
cbushell
2
200
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
81
Continuous Integration, fast builds and Flot
cbushell
2
90
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.5k
The Cost Of JavaScript in 2023
addyosmani
55
10k
WCS-LA-2024
lcolladotor
0
810
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
650
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
230
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
550
The Spectacular Lies of Maps
axbom
PRO
1
950
Navigating Weather and Climate Data
rabernat
0
490
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Testing 201, or: Great Expectations
jmmastey
46
8.3k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
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