Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs-next/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export default defineConfig({
label: "Detecting multiple calls to done()",
slug: "explainers/detecting-multiple-calls-to-done",
},
{
label: "Find global leaks",
slug: "explainers/find-global-leaks",
},
{
label: "Node.js native ESM support",
slug: "explainers/nodejs-native-esm-support",
Expand Down
16 changes: 16 additions & 0 deletions docs-next/src/content/docs/explainers/find-global-leaks.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
description: How to find a global leak.
title: Find global leaks
---

Detecting which module is causing a global leak can be tedious. Add these lines at the very beginning of your tests, or in a file which is included via `--require`:

```javascript
Object.defineProperty(global, 'name_of_leaking_property', {
set: function (value) {
throw new Error('Found the leak!');
}
});
```

This will print a stacktrace that shows which module caused the leak. And if it's not yours--go open a pull request! :)
11 changes: 11 additions & 0 deletions docs/api-tutorials/find-global-leaks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Detecting which module is causing a global leak can be tedious. Add these lines at the very beginning of your tests, or in a file which is included via `--require`:

```javascript
Object.defineProperty(global, 'name_of_leaking_property', {
set: function (value) {
throw new Error('Found the leak!');
}
});
```

This will print a stacktrace that shows which module caused the leak. And if it's not yours--go open a pull request! :)
3 changes: 3 additions & 0 deletions docs/api-tutorials/jsdoc.tutorials.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"custom-reporter": {
"title": "Create a Custom Reporter"
},
"find-global-leaks": {
"title": "Find global leaks"
},
"shared-behaviours": {
"title": "Shared behaviours"
},
Expand Down
Loading