Introduction

This is a continuation to the first part which you can find here. In this part we are going to dive deeper into actual api tests. I will show you some adapted Design patterns in Javascript and we will do full test without any mocks or stubs.

Let’s set up

First we have to set up a single test and Mocha script to run it. We can do this by creating any test in tests/ directory following pattern tests/**/*.test.js. The command to start tests is very simple: mocha tests/**/*.test.js —-reporter dot.

npm run test command

Example test consists of single describe block to define tests suite and…


Introduction

In this story I will build simple restful api with Express and MongoDB. I will set up testing environment with Docker-Compose and write api tests for all my endpoints without any mocks.

About me

I have been a Nodejs enthusiast for almost three years already from entry level developer, to junior full stack engineer and now mid level developer. My career mostly consists of full stack development with Javascript& Typescript frameworks and libraries like AngularJS, ExpressJS, React. I am also somewhat experienced with Devops side of software engineering with tools like Terraform, Docker, Teamcity, Nginx and so on. …


Introduction

In this series of stories I will be building complete NodeJS web server application with ExpressJS library and Typescript. I will use tools like Docker & Docker compose to set up development and testing environment (databases, elk stack etc.). Also I will try to enforce TDD (Test Driven Development) style for building this application with Mocha (Ts-Mocha), Supertest and NodeJS native library Assert.

About me

I have been a NodeJS enthusiast for almost three years already from entry level developer, to junior full stack engineer and now mid level developer. My career mostly consists of full stack development with JavaScript frameworks and…

Liudas Demikis

Full-stack JavaScript developer; Experienced with React, Redux, Node, Express, Mongo, Postgresql, Docker, TypeScript, AWS

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store