Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

docs: migrate to global leak wiki page to docs (#5437)

Kelechi Ebiri8a6fdcafccd9
diff --git a/docs-next/astro.config.ts b/docs-next/astro.config.ts
index 5c4632ee..81ade308 100644
--- a/docs-next/astro.config.ts
+++ b/docs-next/astro.config.ts
@@ -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",
diff --git a/docs-next/src/content/docs/explainers/find-global-leaks.mdx b/docs-next/src/content/docs/explainers/find-global-leaks.mdx
new file mode 100644
index 00000000..b05f9596
--- /dev/null
+++ b/docs-next/src/content/docs/explainers/find-global-leaks.mdx
@@ -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! :)
diff --git a/docs/api-tutorials/find-global-leaks.md b/docs/api-tutorials/find-global-leaks.md
new file mode 100644
index 00000000..ae2e6dff
--- /dev/null
+++ b/docs/api-tutorials/find-global-leaks.md
@@ -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! :)
diff --git a/docs/api-tutorials/jsdoc.tutorials.json b/docs/api-tutorials/jsdoc.tutorials.json
index fe114e56..7d630cc9 100644
--- a/docs/api-tutorials/jsdoc.tutorials.json
+++ b/docs/api-tutorials/jsdoc.tutorials.json
@@ -2,6 +2,9 @@
"custom-reporter": {
"title": "Create a Custom Reporter"
},
+ "find-global-leaks": {
+ "title": "Find global leaks"
+ },
"shared-behaviours": {
"title": "Shared behaviours"
},