Jest Teardown in config file for multiple tests suites

Viewed 345

I'm making an API for a website (this is open source you can find the repo and look by yourself here : https://github.com/PirateSeal/Operation-Green-Axe-2)

I'm making tests suites with jest and supertest and i'm using knex to connect and talk with my db.

My problem is that i can't run multiple tests suites because the first one is "locking" access to my db.

In each of my tests files I implemented the BeforeAll() and AfterAll() methods to create and teardown my db and instead of doing that for each test, i'd like to create a setup file that will run before all tests suites and after all.

I read about jest setup file but i didn't understand how to use it.

Can you help me please ?

(this is my first question here btw pls be kind :) )

0 Answers
Related