Agile JavaScript Testing
Making the web a better place
What?
TDD is...
A Design Method
For better quality




                And less bugs
It Goes like this:
1. Think:
What is this code supposed to do?
How am I going to interact with it?
What would be the simplest, clearest API?
2. Write a test
Test what the code is supposed to do
3. Run the test
It will fail.
4. Write the code
Make the test pass
Repeat...
Confused?
“Don’t tests come after?”
Terminology issues...
“tests”, “assertions”, etc...
Get the words right	
(it’s easier to think)
Behavior Driven Development
same thing, better terminology
In BDD
you write “specs” to describe “behavior”
you describe what you “expect” to occur
It’s more like...
Behavior Driven Development
With Screw.Unit, a BDD framework for JS
http://github.com/nkallen/screw-unit
Oversimplified Example
We need a method of doubling a number
First in plain text
describe doubleIt
 - it returns twice the number passed to it
Now with Screw.Unit
What do we expect?
Now run the spec
Define doubleIt
Run the spec again
You want 4?! Done!
Run the spec again
A couple more expectations
Run the spec again
Refactor the code
Run the spec again
One expectation per spec
Recommended, not always necessary.
Just be pragmatic.
Refactor the specs
Run the spec again
Before / After
Setup and teardown
Higher level - UI interactions
Testing the DOM
Verify JS is doing what we expect to the HTMLs
Testing the DOM
In suite.html (container file), have a special DOM node:




In a before block, set it to it’s default state:
Testing the DOM


In your specs, you can interact with it:
Always more to explore...


 Mocking and Stubbing - using the Smoke library
 Testing / simulating browser events
 Testing / mocking ajax requests and callbacks
Integrate with your workflow
An example using Blue Ridge for Ruby on Rails
Blue Ridge
A JavaScript Testing plugin for Rails

 Run JavaScript tests via the command-line, with a
 head-less browser environment
 Uses Rhino - a Java based JavaScript interpreter
 And env.js - an implementation of the DOM in pure
 JavaScript (thanks John Resig!)
 Screw.Unit and Smoke built in! Plus generators.

http://github.com/relevance/blue-ridge
Always be testing
Run your JS tests at the same time as your
other tests!


Example...
A universe of browsers
each with its own “features” (bugs)
JS Test Driver
Parallel cross-browser testing via command line
JS Test Driver
http://code.google.com/p/js-test-driver/
 Launch the server
 Capture one or more browsers
 Write tests and code
 Run your tests


 Bonus: Continously run tests, whenever files change
Future / Other
 Test Swarm: Distributed Continous Integration for JS
 http://testswarm.com


 JSpec: An alternative BDD framework for JS
 http://visionmedia.github.com/jspec
Thanks!
Scott Becker
becker.scott@gmail.com
http://synthesis.sbecker.net

More Related Content

PDF
Module, AMD, RequireJS
PDF
Painless JavaScript Testing with Jest
PDF
Javascript Test Automation Workshop (21.08.2014)
PPT
Testing in AngularJS
PDF
Night Watch with QA
PDF
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
PDF
Angularjs - Unit testing introduction
PDF
Intro to testing Javascript with jasmine
Module, AMD, RequireJS
Painless JavaScript Testing with Jest
Javascript Test Automation Workshop (21.08.2014)
Testing in AngularJS
Night Watch with QA
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
Angularjs - Unit testing introduction
Intro to testing Javascript with jasmine

What's hot (20)

PDF
JavaScript TDD with Jasmine and Karma
PDF
System webpack-jspm
ODP
Unit Testing and Coverage for AngularJS
PDF
AngularJS Unit Testing w/Karma and Jasmine
PDF
Intro To JavaScript Unit Testing - Ran Mizrahi
ZIP
Automated Frontend Testing
PDF
Javascript TDD with Jasmine, Karma, and Gulp
PPTX
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
PDF
Unit Testing with Jest
PDF
Advanced Jasmine - Front-End JavaScript Unit Testing
PPTX
A few good JavaScript development tools
PDF
Quick tour to front end unit testing using jasmine
PDF
Unit and functional testing with Siesta
PDF
Survive JavaScript - Strategies and Tricks
PDF
Testing javascript in the frontend
PPTX
Unit testing JavaScript: Jasmine & karma intro
PPTX
Unit testing in JavaScript with Jasmine and Karma
PDF
Jasmine BDD for Javascript
PDF
Using JHipster for generating Angular/Spring Boot apps
PDF
Asynchronous Module Definition (AMD)
JavaScript TDD with Jasmine and Karma
System webpack-jspm
Unit Testing and Coverage for AngularJS
AngularJS Unit Testing w/Karma and Jasmine
Intro To JavaScript Unit Testing - Ran Mizrahi
Automated Frontend Testing
Javascript TDD with Jasmine, Karma, and Gulp
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
Unit Testing with Jest
Advanced Jasmine - Front-End JavaScript Unit Testing
A few good JavaScript development tools
Quick tour to front end unit testing using jasmine
Unit and functional testing with Siesta
Survive JavaScript - Strategies and Tricks
Testing javascript in the frontend
Unit testing JavaScript: Jasmine & karma intro
Unit testing in JavaScript with Jasmine and Karma
Jasmine BDD for Javascript
Using JHipster for generating Angular/Spring Boot apps
Asynchronous Module Definition (AMD)
Ad

Viewers also liked (20)

PDF
Efficient JavaScript Unit Testing, May 2012
PPTX
Test-Driven JavaScript Development (JavaZone 2010)
PDF
Test your Javascript! v1.1
PDF
High Performance JavaScript 2011
PDF
Maintainable JavaScript 2011
PDF
Scalable JavaScript Application Architecture
PDF
AngularJS Deep Dives (NYC GDG Apr 2013)
PDF
The Art of AngularJS - DeRailed 2014
PPTX
React in Native Apps - Meetup React - 20150409
PDF
React JS and why it's awesome
PPTX
Becoming Node.js ninja on Cloud Foundry
PPTX
Testing nodejs apps
PDF
Building a Single-Page App: Backbone, Node.js, and Beyond
PDF
[C5]deview 2012 nodejs
PDF
Compose Async with RxJS
PPTX
소셜게임 서버 개발 관점에서 본 Node.js의 장단점과 대안
PDF
프론트엔드 웹앱 프레임웍 - Bootstrap, Backbone 그리고 AngularJS
KEY
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
PDF
RESTful API Design, Second Edition
KEY
Intro To Sammy
Efficient JavaScript Unit Testing, May 2012
Test-Driven JavaScript Development (JavaZone 2010)
Test your Javascript! v1.1
High Performance JavaScript 2011
Maintainable JavaScript 2011
Scalable JavaScript Application Architecture
AngularJS Deep Dives (NYC GDG Apr 2013)
The Art of AngularJS - DeRailed 2014
React in Native Apps - Meetup React - 20150409
React JS and why it's awesome
Becoming Node.js ninja on Cloud Foundry
Testing nodejs apps
Building a Single-Page App: Backbone, Node.js, and Beyond
[C5]deview 2012 nodejs
Compose Async with RxJS
소셜게임 서버 개발 관점에서 본 Node.js의 장단점과 대안
프론트엔드 웹앱 프레임웍 - Bootstrap, Backbone 그리고 AngularJS
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
RESTful API Design, Second Edition
Intro To Sammy
Ad

Similar to Agile JavaScript Testing (20)

PPTX
All of Javascript
PPTX
Java script unit testing
PPT
Testing Storm components with Groovy and Spock
PPTX
Real World Single Page App - A Knockout Case Study
PDF
Intro to mobile web application development
PDF
TDD super mondays-june-2014
PPTX
All of javascript
PDF
Class 6: Introduction to web technology entrepreneurship
PDF
David Nuescheler: Igniting CQ 5.3: What's New and Roadmap
PDF
Fewd week4 slides
PDF
Maintainable Javascript carsonified
PPTX
Node.js meetup 17.05.2017 ember.js - escape the javascript fatigue
PDF
Basic JavaScript Tutorial
PDF
Meetup React Sanca - 29/11/18 - React Testing
PPT
Js unit testing
PDF
The Mysteries Of JavaScript-Fu (@media SF Edition)
PPTX
Flu3nt highlights
PPTX
Testing of React JS app
PDF
Your java script library
PDF
Beginning AngularJS
All of Javascript
Java script unit testing
Testing Storm components with Groovy and Spock
Real World Single Page App - A Knockout Case Study
Intro to mobile web application development
TDD super mondays-june-2014
All of javascript
Class 6: Introduction to web technology entrepreneurship
David Nuescheler: Igniting CQ 5.3: What's New and Roadmap
Fewd week4 slides
Maintainable Javascript carsonified
Node.js meetup 17.05.2017 ember.js - escape the javascript fatigue
Basic JavaScript Tutorial
Meetup React Sanca - 29/11/18 - React Testing
Js unit testing
The Mysteries Of JavaScript-Fu (@media SF Edition)
Flu3nt highlights
Testing of React JS app
Your java script library
Beginning AngularJS

Recently uploaded (20)

PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PPTX
TEXTILE technology diploma scope and career opportunities
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
Enhancing plagiarism detection using data pre-processing and machine learning...
PDF
CloudStack 4.21: First Look Webinar slides
PDF
Five Habits of High-Impact Board Members
PPTX
Configure Apache Mutual Authentication
PDF
Improvisation in detection of pomegranate leaf disease using transfer learni...
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PDF
Statistics on Ai - sourced from AIPRM.pdf
PDF
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
STKI Israel Market Study 2025 version august
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
Comparative analysis of machine learning models for fake news detection in so...
PDF
Architecture types and enterprise applications.pdf
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
The influence of sentiment analysis in enhancing early warning system model f...
TEXTILE technology diploma scope and career opportunities
Convolutional neural network based encoder-decoder for efficient real-time ob...
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Enhancing plagiarism detection using data pre-processing and machine learning...
CloudStack 4.21: First Look Webinar slides
Five Habits of High-Impact Board Members
Configure Apache Mutual Authentication
Improvisation in detection of pomegranate leaf disease using transfer learni...
Module 1.ppt Iot fundamentals and Architecture
sustainability-14-14877-v2.pddhzftheheeeee
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
Statistics on Ai - sourced from AIPRM.pdf
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
STKI Israel Market Study 2025 version august
NewMind AI Weekly Chronicles – August ’25 Week III
Comparative analysis of machine learning models for fake news detection in so...
Architecture types and enterprise applications.pdf

Agile JavaScript Testing