To use the docker functionality , first install Docker/Docker Compose.
For a previous project I needed a back-end and used a simple external API. When doing another private project I realised that I should not use someone elses backend if I want to store user-data. I am therefore trying to learn it for myself. Since I already know JavaScript , Node and Express seem the obvious tools. I am using test driven development for this project, both for actual testing before deploying and for declaring what I want the API to return before i'm writing the code. It also functions as a sort of documentation on how the app is intended to work.
Jest and Node seem to have problems using ES6 syntax. You would have to use the old way of importing/exporting like so:
Importing:
const express = require("express");
Exporting:
module.exports = { thisFunction, thatVariable };
For someone like me, who wants to use ES6 syntax there is a solution.
Some changes in the package.json file should do the trick...
For using ES6 modules in node set type attribute in package.json to module,like this:
"type": "module",
To avoid getting into trouble with Jest, we also need to change how we run the tests by defining the test script as follows:
"test": "NODE_OPTIONS=--experimental-vm-modules npx jest",
Link to relevant info from Sam Meechward and Jest website. For insight into the difference between Common JS modules and ES6 modules, I found this website enlightening.
As a starter I am going to set the server up for a todo-list app. I will use TDD with Jest, so I need to examine how to use Jest with a node/express app and how to test a server.
I came across a few videos that use a combination of Jest and Supertest. Supertest is a NPM package that provides a high level abstraction for testing HTTP. More on this here.
In the end I would have to deploy the server somewhere. Options for that are :