Peter Banjo
Soliloquy

Soliloquy

Get TDD

Photo by Joshua Hanson on Unsplash

Get TDD

Peter Banjo's photo
Peter Banjo
ยทApr 19, 2022ยท

1 min read

Play this article

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.

โœŒ๏ธ

ย 
Share this