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.

test

Milly
Vienna, Austria

Intermediate

test

Milly
Vienna, Austria

Intermediate

Featured Partners

Related Articles

View all articles
CH
Chris Heilmann
Dev Digest 136 - No JS(on) of mine
News and ArticlesDouglas Crockford is our featured video, so let's talk about evolving JavaScript and all things JSON. Judicious JSON explains all the weird things in it, you can learn why it can be incredibly slow, people wonder what even is a JSON ...
Dev Digest 136 - No JS(on) of mine
LM
Luis Minvielle
10 Developer Websites in 2023
As a web developer, you're always investigating how to level up your skills and streamline your workflow. That's why we've gathered a collection of 10 innovative tools that are guaranteed to boost your productivity, enhance your coding abilities, ele...
10 Developer Websites in 2023
DC
Daniel Cranney
The real reason we document our code
The world of software development moves fast. Technology is constantly changing, as are the tools we use with it, and even the role of a programmer is itself constantly in flux. However, some aspects of software engineering are so foundational that w...
The real reason we document our code
AL
Anna Lysiuk
10 Coding Habits That Make You a Bad Programmer
Computer programming is crucial in today’s automated world. It makes it possible for people to interact with machines more efficiently and accurately. Computer programmers use a variety of computer languages to create codes that make it possible for ...
10 Coding Habits That Make You a Bad Programmer

From learning to earning

Jobs that call for the skills explored in this talk.