TDD with AdonisJs (4 Part Series)
AdonisJs is great for test driven development. We will build an API for a simple version of reddit using TDD. It will consist of subforums, threads, comments and users. You can find the GitHub for it here: https://github.com/MZanggl/tdd-adonisjs/commit/b2582b286e4da0166f30a8d6a8eee7c3aeb1c8bb.
Without further ado, let's get the project set up!
npm i -g @adonisjs/cli
In this course we want to focus only on the adonis part and not the frontend, so let's create the project using the "api only" flag.
adonis new forum --api-only cd forum
adonis install @adonisjs/vow
We have to add the vowProvider under "start/app.js" in the aceProviders array.
const aceProviders = [ '@adonisjs/vow/providers/VowProvider', ]
The installation of vow comes with an example test, run
npm test or simply
npm t to run it.
To make sure things are working, run the project using
adonis serve --dev and head to the url in your browser!
And that's all there is to it, in the next blog post we will create our first test!