after is called at wrong time.
weepy opened this issue · 1 comments
weepy commented
I was having trouble with getting the "after" test callback to run at the right time.
// setup.js
import { test } from 'uvu'
test.before(async () => {
dropDatabase()
})
test.after(async () => {
closeDatabaseConnection()
})
// test-a.js
import "./setup.js"
import { test } from 'uvu'
test("should do something with database.", async () => ... )
// test-b.js
import "./setup.js"
import { test } from 'uvu'
test("should do something else with database.", async () => ... )
Now I was hoping that the closeDatabaseConnection()
is called after both test's a and b are finished, but in fact it is called when test-a is finished, which is not useful since it closes the database connection and then test-b fails
The only work around I have got to work is creating a "zzz-teardown.js" file with the test.after within it - which is sorta guaranteed to run last bc of the filename. Obviously not a very nice hack.
Am I doing something wrong, or is there a better workaround or fix ?