Skip to content

Commit

Permalink
Update Knex config to avoid hanging promises
Browse files Browse the repository at this point in the history
When trying to work with the DB in the tests we were getting

```
Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
```

Googling led us to [Having trouble running Jest, unhandled Promises](Vincit/objection.js#1015) and [Need to explicit destroy knex in order to stop the script](Vincit/objection.js#534). The second issue included a comment that setting the pool min size to 0 and idleTimeoutMillis to 500 would solve the problem. We tried it and it worked!
  • Loading branch information
Cruikshanks committed Sep 28, 2023
1 parent a6eb5ac commit 9411245
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions knexfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const development = {

const test = {
...defaultConfig,
pool: { min: 0, idleTimeoutMillis: 500 },
connection: {
...defaultConnection,
database: DatabaseConfig.testDatabase
Expand Down

0 comments on commit 9411245

Please sign in to comment.