-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
72 additions
and
2 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
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
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
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 @@ | ||
import { _initialiseInstanceRegistry } from "miniflare"; | ||
|
||
const registry = _initialiseInstanceRegistry(); | ||
const bigSeparator = "=".repeat(80); | ||
const separator = "-".repeat(80); | ||
|
||
// `process.on("exit")` is more like `worker_thread.on(`exit`)` here. It will | ||
// be called once AVA's finished running tests and `after` hooks. Note we can't | ||
// use an `after` hook here, as that would run before `miniflareTest`'s | ||
// `after` hooks to dispose their `Miniflare` instances. | ||
process.on("exit", () => { | ||
if (registry.size === 0) return; | ||
|
||
// If there are Miniflare instances that weren't disposed, throw | ||
const s = registry.size === 1 ? "" : "s"; | ||
const was = registry.size === 1 ? "was" : "were"; | ||
const message = `Found ${registry.size} Miniflare instance${s} that ${was} not dispose()d`; | ||
const stacks = Array.from(registry.values()).join(`\n${separator}\n`); | ||
console.log( | ||
[bigSeparator, message, separator, stacks, bigSeparator].join("\n") | ||
); | ||
throw new Error(message); | ||
}); |
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