Skip to content

MarkBennett/IntroToJsTdd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

This repository is a demonstration of how to use Test Driven Development with Javascript.

Test Driven Development is software development process that relies on the repetion of a very short development cycle: first you write a test, watch your tests fail, then refactor your code until the tests pass. This test-first process is repeated until the application is complete.

There are many different Javascript TDD frameworks, including:

For this demonstration I'll be using qUnit as it has a nice browser based test runner. The same concepts should apply to other frameworks as well.

I'm also going to assume that you're reasonably familiar with Javascript. If you aren't I highly recommend these excellent books to get you started:

To get started we've downloaded qUnit and created a simple scaffolding.

Clone this repository and reset it to the commit your interested in (in this case the first one, ac3e163395):

$ git clone git@github.com:MarkBennett/IntroToJsTdd.git
$ git reset --hard <commit>

We've now got five files in our directory:

  • my_script.js
  • test/index.html
  • test/tests.js
  • test/qunit/qunit.js
  • test/qunit/qunit.css

This scaffolding comes straight from the qUnit repo.

To begin try running your tests by opening test/index.html in your browser. If everything worked you should see a clean test runner. When you've got it working move on to the next commit to see how we add a new test.

About

Introduction To Javascript TDD

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published