Sascha Depold & Parinaz Roghany

Test Driven Development with JavaScript

First, write a test that fails. Then, write the code to make it pass. This simple rhythm is the key to building truly robust software.

Test Driven Development with JavaScript
#1about 5 minutes

The fundamentals of software testing

Learn the difference between manual and automated testing, the various types like unit and integration, and why testing is crucial for product health.

#2about 2 minutes

Understanding the Test-Driven Development (TDD) workflow

TDD involves converting feature specifications into machine-readable tests before writing any implementation code.

#3about 3 minutes

Choosing the right JavaScript testing tools

An overview of the JavaScript testing ecosystem compares the all-in-one Jest framework with the combination of Mocha and Chai.

#4about 10 minutes

Preparing to implement the Fibonacci sequence with TDD

The Fibonacci sequence is introduced as the coding challenge, and the Red-Green-Refactor strategy is outlined for its implementation.

#5about 17 minutes

Live coding: Writing the Fibonacci unit tests

A step-by-step guide to writing unit tests for the Fibonacci function using Mocha's `describe` and `it` blocks and Chai's `expect` assertions.

#6about 10 minutes

Live coding: Implementing the function to pass tests

The Fibonacci function is implemented incrementally, running the test suite after each change to watch the tests turn from red to green.

#7about 3 minutes

Addressing performance issues with large numbers

An explanation of why the recursive implementation is slow for large inputs and how to solve precision issues using JavaScript's `BigInt`.

#8about 10 minutes

Applying TDD principles to API testing

The workshop transitions from unit testing to integration testing by setting up an Express.js API and using SuperTest to define its behavior via tests.

#9about 14 minutes

Writing API tests and handling external dependencies

Learn to write API tests with SuperTest and discover why making real network requests to external services makes your test suite slow and unreliable.

#10about 14 minutes

Mocking dependencies with Sinon and Nock

Use Sinon.js to mock modules and Nock.js to mock HTTP requests, effectively isolating your tests and making them significantly faster.

#11about 13 minutes

Recap and practical advice for testing applications

A summary of key takeaways, including a discussion on what to test in frontend applications and how to introduce TDD to junior developers.

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

Featured Partners

Related Articles

View all articles
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
What Developers Really Need to Create Great Code Demos
Every developer on earth has, at some point, had another developer to thank for a breakthrough, a success, an aha moment they wouldn’t have had without coming across that blog post, that open-source contribution, that reply on socials or that humble ...
What Developers Really Need to Create Great Code Demos
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

From learning to earning

Jobs that call for the skills explored in this talk.

Java Software Engineer

Java Software Engineer

Test Driven Solutions
Edinburgh, United Kingdom

Intermediate
Java
MySQL
NoSQL
Scrum
Jenkins
+4
Creative Javascript

Creative Javascript

Thegiglab
Amsterdam, Netherlands

Intermediate
API
CSS
HTML
jQuery
Bootstrap
+1
Automated Tester

Automated Tester

The Trust
Rishangles, United Kingdom

Remote
GIT
Java
JIRA
REST
+4