Cover image for TDD course with AdonisJs - 1. Let's build a reddit clone

TDD course with AdonisJs - 1. Let's build a reddit clone

michi profile image Michael Z Updated on 惻1 min read

Originally posted at michaelzanggl.com. Subscribe to my newsletter to never miss out on new content.

AdonisJs is great for test driven development. Let's 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!

Install CLI and framework

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

Install testing library

Adonis comes with its own testing library, let's install it with

adonis install @adonisjs/vow

We have to add the vowProvider under "start/app.js" in the aceProviders array to register the adonis test commands.

const aceProviders = [

The installation of vow comes with an example test, run adonis test, 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!

Posted on by:


markdown guide