-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(test): clear and close lmdb after each test suite (#36343)
- Loading branch information
Showing
4 changed files
with
64 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const NodeEnvironment = require(`jest-environment-node`) | ||
|
||
class CustomEnvironment extends NodeEnvironment { | ||
constructor(config, context) { | ||
super(config, context) | ||
} | ||
|
||
async teardown(): Promise<void> { | ||
// close open lmdbs after running test suite | ||
// this prevent dangling open handles that sometimes cause problems | ||
// particularly in windows tests (failures to move or delete a db file) | ||
if (this.global.__GATSBY_OPEN_ROOT_LMDBS) { | ||
for (const rootDb of this.global.__GATSBY_OPEN_ROOT_LMDBS.values()) { | ||
await rootDb.clearAsync() | ||
await rootDb.close() | ||
} | ||
this.global.__GATSBY_OPEN_ROOT_LMDBS = undefined | ||
} | ||
await super.teardown() | ||
} | ||
} | ||
|
||
module.exports = CustomEnvironment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters