James Bender

Yes, You Need to Unit Test your JavaScript. Here's How.

Stop the slow slog to the end. Learn how TDD creates a safety net, letting you build and refactor with confidence.

Yes, You Need to Unit Test your JavaScript. Here's How.
#1about 7 minutes

Why developers avoid unit testing JavaScript

Common excuses for not unit testing are addressed by framing tests as a long-term investment that prevents project slowdowns.

#2about 5 minutes

Understanding the Test-Driven Development workflow

TDD inverts the traditional development process by using specifications to write automated tests before writing the implementation code.

#3about 7 minutes

The core characteristics of a good unit test

Effective unit tests are isolated from dependencies, targeted to a single scenario, and repeatable regardless of external factors.

#4about 5 minutes

Applying the red-green-refactor TDD cycle

The core TDD loop involves writing a failing test (red), writing minimal code to pass it (green), and then improving the code's design (refactor).

#5about 2 minutes

Choosing a JavaScript testing framework: Jest vs Jasmine

Jest is recommended over Jasmine primarily for its performance benefits, as it runs tests in a multi-threaded environment.

#6about 8 minutes

Writing your first basic unit test with Jest

A live coding demonstration introduces the basic Jest syntax, including the `test`, `expect`, and `toBe` functions for a simple sum operation.

#7about 14 minutes

Live coding a Tic-Tac-Toe game using TDD

This demonstration builds a simple game engine by following the red-green-refactor cycle and using BDD-style tests with `describe` and `it`.

#8about 2 minutes

Practical next steps for adopting unit testing

Actionable advice for teams includes starting with new features, practicing daily, sharing knowledge, and measuring code coverage.

#9about 9 minutes

Audience Q&A on testing strategies

Questions from the audience are answered, covering topics like integration testing in React, handling front-end tests, and involving product teams.

Related jobs
Jobs that call for the skills explored in this talk.

Featured Partners

Related Articles

View all articles
DC
Daniel Cranney
Exploring TypeScript: Benefits for Large-Scale JavaScript Projects
JavaScript is the backbone of web development, powering everything from small websites to large-scale enterprise applications. However, as projects grow in complexity, maintaining JavaScript code can become increasingly difficult. This is where TypeS...
Exploring TypeScript: Benefits for Large-Scale JavaScript Projects
DC
Daniel Cranney
Dev Digest 195: End of Likes, JavaScript’s a Zoo, and Messing with Bots!
Inside last week’s Dev Digest 195 . 👎 No more external likes 🤗 Needy programs 📉 The worst selling Microsoft product 🟨 JavaScript engines zoo 🍞 No more toasts! 🤖 Messing with bots 👔 Beware of fake job interviews 🗞️ Join over 150,000 developers alread...
Dev Digest 195: End of Likes, JavaScript’s a Zoo, and Messing with Bots!
BR
Benjamin Ruschin
The HTML Elements That You’re Probably Over-Engineering
As frameworks have become more and more commonplace in the world of web development, so too has the over-engineering of features made possible by our humble old friend, HTML. The mental models that come with using state management in React, Vue and o...
The HTML Elements That You’re Probably Over-Engineering

From learning to earning

Jobs that call for the skills explored in this talk.

Software Tester (f/m/d)

Software Tester (f/m/d)

Power Plus Communications
Mannheim, Germany

Intermediate
Senior
Python
Unit Testing
Automated Testing