Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run tests #79

Open
c1oneman opened this issue Oct 27, 2021 · 2 comments
Open

Unable to run tests #79

c1oneman opened this issue Oct 27, 2021 · 2 comments

Comments

@c1oneman
Copy link

c1oneman commented Oct 27, 2021

api-design-v3@1.0.0 test-routes
npm run test -t router

api-design-v3@1.0.0 test
cross-env NODE_ENV=testing jest --forceExit --detectOpenHandles --silent "router"

RUNS src/resources/item/tests/item.router.spec.js
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "TypeError: Cannot read properties of undefined (reading 'dropDatabase')".] {
code: 'ERR_UNHANDLED_REJECTION'
}

@toddtyler
Copy link

toddtyler commented Nov 19, 2021

I was able to get past this by editing test-db-setup.js and changing the afterEach() function to include a try/catch:

afterEach(async done => {
  try {
    await mongoose.connection.db.dropDatabase()
    await mongoose.disconnect()
  } catch (err) {
    console.log(err)
  }
  await mongoose.disconnect()
  return done()
})
afterAll(done => {
  return done()
})

@jhhornn

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants