How to refresh the DB after each teste inside a suite?

I try to follow this tutorial but, doesn’t work , i tryng something using afterEach but i dont know the syntaxe or how to use them.

I try this:

afterEach(async () => {
await ace.call(‘migration:refresh’, {}, { silent: true })
})

what works fine to them run the last time, in this last time, i receive this error

Error: Hook timeout, ensure “done()” is called; if retur
ning a Promise, ensure it resolves.
at Hook._parseError (C:\Users\noob-\Documents\Projetos
\KnowHow GitHub\node_modules\japa\src\Hook.js:42:16)
at C:\Users\noob-\Documents\Projetos\KnowHow GitHub\no
de_modules\japa\src\Hook.js:110:22

Soo i try this:

after(async () => {
use(‘Adonis/Src/Server’).getInstance().close()
})

And doesn’t resolve but give a equal second error.

I doesn’t understand why or how i can end this hook.

:sos: help :sos:

1 Like

The way i found to resolve this problem is using the trait (“documentation” here)

trait(‘DatabaseTransactions’)

inside a While function, This way is easier than the way I was trying to do

2 Likes