Closed
Description
After the upgrade from 0.25.0
to 1.0.0-beta8
I'm getting this error because I have a before
and after.always
hook in a helper file:
test.before(async t => {
const uri = await mongod.getConnectionString()
await mongoose.connect(uri, {
useNewUrlParser: true
})
})
test.after.always(async t => {
mongoose.connection.db.dropDatabase()
})
But I'm getting this error Error: All tests and hooks must be declared synchronously in your test file, and cannot be nested within other tests or hooks.
now.
I used to import the above helper file in every test file.
I'm wondering what the proper approach is to set up a global before and after hook because I only want to init and destroy my database once... I don't want to do this per file because mongoose will be confused and I want all my tests to run in parallel on the same database since that is a real life scenario that I want to test.
How should I structure this?
Metadata
Metadata
Assignees
Labels
No labels