Skip to main content

Command Palette

Search for a command to run...

Get TDD

Published
1 min read
Get TDD
P

I build meaningful software by empathising with design, development and business needs. My interests are test automation, functional programming and full-stack web development using NodeJS and other tools.

In a world where APIs rule the web and JavaScript is the language that reigns across all the stacks, one framework shall rise to challenge the Kingdom of Express.

Introduction

Fastify, first of its name, is a low overhead (aka. fast) server-side JavaScript framework. Express is currently the most popular NodeJs framework and Fastify is compatible with Express. What makes Fastify a beauty 🌸 is that it's faster, has more features and makes testing our APIs so easy.

What we are going to build together is a simple Calculator API. When we POST an array of numbers e.g. [2, 4] our API will add them together and return 6. It's simple so we keep our attention on testing.

Test-Driven 🚘

Test-Driven Development is a programming practice where:

  • Tests are written before operational code
  • Operational Code is updated to make the tests pass
  • Code is refactored to improve its design

This is commonly known as Red, Green and Refactor. It reminds me of traffic lights 🚥.

Plan

The plan is that I will create a blank repo and open PR's so you can see how we can evolve an API using tests.

If you would like to skip ahead, take a look at this Github repository.

See you soon.

✌️

More from this blog

S

Soliloquy

26 posts

Father, husband, cosmopolitan geek and music lover. Learning how to build beautiful things.