Skip to content
A simple live search jQuery plugin, developed to showcase TDD with JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Live search, a JavaScript TDD showcase

Read the article:

The code itself is very crude - this is just the start of a plugin. Note that it does not do anything other than display a list of suggestions. No keyboard navigation, no ability to select suggestions, no nothing. This is only an example of how I use TDD to develop code - there is only so much you can show in a single article.

To actually take the code for a spin, concatenate the source files like so:

cat client/lib/jquery.js client/src/list_renderer.js\
      client/src/xhr_data_source.js client/src/live_search.js\
      client/src/live_search.jquery.js > server/public/live-search.min.js

Then run the server (you'll need Node.js 0.4.8 or higher)

cd server
npm link

Then visit localhost:8000/ and type something in the search box. Suggestions should show up.

I wish I could tell you that I took the time to TDD the server code as well, but unfortunately, it's a complete mess, and I only hacked it together in order to show the demo with some results.

To run the tests:

cd client && java -jar path/to/JsTestDriver-1.2.2.jar --tests all

I recommend Jstdutil (

Something went wrong with that request. Please try again.