Building Quality JavaScript With Test-Driven Development

By Steven Hicks

Elevator Pitch

This workshop will ease the frustration of learning Test-Driven Development. We’ll discuss the fundamentals of TDD and work together to solve problems in a test-driven manner. You’ll build confidence in your ability to apply TDD in JavaScript with hands-on experience.

Description

Learning Test-Driven Development (TDD) is frustrating. The first couple tests feel strange - you wonder why you’re writing tests that fail on purpose. Before long, you find yourself behind schedule from spending so much time on tests. You abandon unit testing completely. You’ll write them after….if you find the time.

This workshop will ease the frustration of learning Test-Driven Development. We’ll discuss the fundamentals of TDD and work together to solve problems in a test-driven manner. You’ll build confidence in your ability to apply TDD in JavaScript with hands-on experience.

Topics and activities include:

  • Instruction and exercises that will familiarize you with Jest as a JavaScript test framework
  • An introduction to the fundamentals of TDD
  • An instructor-led demonstration of TDD in practice
  • A collaborative code kata to get a hands-on, practical introduction to TDD
  • A series of hands-on exercises writing test-driven JavaScript code
  • A discussion of best practices for keeping your JavaScript test-friendly

We’ll be using Jest to build quality into our JavaScript code from the start. No specific UI framework will be targeted in this workshop - we will focus on writing and testing pure JavaScript. The experience you gain will be applicable to any JavaScript-based app, regardless of your framework allegiance.

Participants should be able to read and write JavaScript, as no time will be spent on language details. General familiarity with writing unit tests in any language is required. Familiarity with Test-Driven Development is helpful but not required, and no TDD experience is necessary. No experience with Jest is necessary.

A laptop with the LTS version of NodeJS installed (currently 8.9.4) is required. The corresponding version of NPM (currently 5.6.0) is also required. A URL with specific prerequisite instructions and code/instructions for the exercises will be provided prior to the event.

Notes

I have led this workshop at Music City Code in Nashville in 2018, and at the Kansas City Developer Conference in 2019.

At Music City Code, it received an average rating of 4.7/5.0 from attendees. Comments included:

  • Very helpful, answers questions well, and provided relevant and helpful content on a tough subject.
  • Very Thorough and well planned src files. Great job!
  • Engaging speaker, great examples

I am a full-stack web developer with nearly 20 years of experience. I’ve always been interested in building quality software. For the last 7 years, I’ve accomplished this with automated testing; for the last 4 years, with Test-Driven Development.

Learning TDD was a struggle for me. It took me two years of practice before I felt any confidence. I know it has also been a struggle for many others. This workshop will give participants a boost in learning TDD, in hopes that they feel confidence more quickly.

Following is an outline, with expected timings:

  • 0:00 - 0:15 - Intro & Setup
  • 0:15 - 0:30 - Jest (instruction)
  • 0:30 - 0:55 - Jest (hands-on exercise)
  • 0:55 - 1:15 - TDD (instruction)
  • 1:15 - 1:30 - TDD (collaborative exercise)
  • 1:30 - 1:40 - break
  • 1:40 - 1:45 - Code Katas (instruction)
  • 1:45 - 2:15 - Paired Code Kata (hands-on exercise)
  • 2:15 - 2:25 - Real-life TDD (instruction)
  • 2:25 - 2:55 - Real-life TDD (hands-on exercise)
  • 2:55 - 3:05 - break
  • 3:05 - 3:10 - Advanced Code Kata (instruction)
  • 3:10 - 3:50 - Paired Advanced Code Kata (hands-on exercise)
  • 3:50 - 4:00 - Good Practices & Summary (instruction)