JavaScript Congress Nov 24, 2021

How to TDD in legacy code

Gil Zilberfeld

Does your old codebase resist test-driven development? Discover how characterization tests and strategic pre-refactoring can safely untangle complex anti-patterns and bring TDD to legacy systems.

Pause
Mute Enter Fullscreen
#1 about 2 min

The basic concept of test-driven development

The standard red-green-refactor cycle provides a structured framework for code generation on greenfield projects.

#2 about 3 min

Challenges of applying test automation to legacy code

Complex dependencies and code resistance make traditional testing methodologies risky in existing codebases.

#3 about 2 min

The practical value of writing automated tests

Immediate feedback from automated test suites accelerates feature delivery and isolates implementation bugs.

#4 about 4 min

Adapting test-driven methodologies for existing systems

Adopting characterization assertions and pre-refactoring strategies bridges the gap between test-driven development and legacy systems.

#5 about 3 min

Analyzing a messy legacy calculator application

A poorly written calculator module with duplicated logic and incomplete functionality highlights the challenges of untested architecture.

#6 about 3 min

Writing characterization tests to document existing behavior

Mapping out current system capabilities with characterization tests safely documents expected behaviors before source modifications.

#7 about 7 min

Fixing software bugs using test-driven principles

Capturing a flaw via a failing assertion ensures only the minimal necessary patch is applied prior to cleanup.

#8 about 7 min

Pre-refactoring complex codebases before adding functionality

Flattening convoluted arrow structures with guard clauses and switch statements prepares legacy functions for new feature logic.

#9 about 4 min

Implementing new behavior and extracting helper methods

Writing targeted tests before feature patches allows raw implementation details to be safely extracted into abstract operations.

#10 about 6 min

Summary of testing steps for legacy systems

Characterization testing limits, localized patches, and continuous cleanliness practices reliably minimize legacy deployment risk.

#11 about 9 min

Testing guard clauses and behavior-driven development strategies

Edge case assertions, behavior-driven stories, and snapshot validation mechanisms offer proven solutions for inherently untestable modules.

Matching moments

2:02 min

Building test infrastructure for existing legacy projects

Alexandre Borges · World Congress 2023

4:42 min

Identifying scenarios where strict test driven development limits agility

James Bender · LIVE

2:52 min

Navigating legacy projects lacking existing unit tests

Annelore Egger Annelore Egger · World Congress 2025

8:22 min

Navigating legacy systems and unconventional software testing practices

Philipp-Alexander Blum · LIVE

4:00 min

Adopting test-driven design as a strategic development methodology

Mirjam Aulbach · World Congress 2022

1:27 min

Understanding the fundamental test-driven development loop

Nadeen Hussein Nadeen Hussein · World Congress 2024

Upcoming sessions on this topic

Open session

World Congress 2026 North America

September 25, 2026 · 13:30–14:00

Stage 7

Agents Can't Iterate Against Tests That Lie

Rocky Warren

Senior Staff Software Engineer at Clipboard

Rocky Warren
Open session

World Congress 2026 North America

September 25, 2026 · 11:40–12:10

Stage 2

Reinventing Testing Practices in the AI Era

Eric Deandrea

Java Champion & Senior Principal Software Engineer at IBM

Eric Deandrea
Open session

World Congress 2026 North America

September 24, 2026 · 16:10–16:40

Stage 2

The Death of the Code Review

Laurie Voss

Head of Developer Relations

Laurie Voss
Open session

World Congress 2026 North America

September 24, 2026 · 14:10–14:40

Stage 9

One Repo, One Strategy: Scalable Full-Stack Testing in a Monorepo World

Bartosz Leczycki, Paweł Matynia

Bartosz Leczycki
Paweł Matynia
Open session

World Congress 2026 North America

September 25, 2026 · 10:20–10:50

Stage 9

Testing React Backends Like a Pro: Mocking Databases with SQLite

David Morris

Solution Architect at Leidos

David Morris
Open session

World Congress 2026 North America

September 25, 2026 · 14:50–15:20

Tech Leaders Stage

Keeping Code Quality at AI Speed

Daksh Gupta, Arthur Hicken, Jack Danger

Daksh Gupta
Arthur Hicken
Jack Danger