Skip to content

Conversation

TG199
Copy link
Contributor

@TG199 TG199 commented Sep 12, 2025

PR Checklist

Overview

Migrate 3 HOW-TO wiki pages to both docs systems:

  • HOW-TO: Correctly stub stdout
  • HOW-TO: Use environment variables
  • Mess with globals

Part of #5248 wiki migration effort

   Migrate 3 HOW-TO wiki pages to both docs systems:
   - HOW-TO: Correctly stub stdout
   - HOW-TO: Use environment variables
   - Mess with globals

   Part of mochajs#5248 wiki migration effort
@TG199 TG199 changed the title docs: migrate HOW-TO wiki pages to main documentation Docs: migrate HOW-TO wiki pages to main documentation Sep 12, 2025
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip: please make sure the site builds before sending a PR 🙂

@@ -0,0 +1,36 @@
---
description: Learn how to use environment variables in Mocha tests
title: HOW-TO: Use environment variables
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get a build error on this and the other HOW-TO file:

docs → explainers/environment-variables.mdx frontmatter does not match collection schema.
title: Required

The title: frontmatter is indeed invalid. You'll need to escape it with quotes. The : is getting interpreted as invalid YML.

title: "HOW-TO: Use environment variables"

That being said, I don't think there's any need to keep to the HOW-TO. All of these "Explainers" section pages are variants of "how to" guides. So, I would say it should match the existing titles convention:

Suggested change
title: HOW-TO: Use environment variables
title: Environment variables

Comment on lines +34 to +36
Any issues or questions please contact us on Gitter.

Thanks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too much copypasta 🍝

Suggested change
Any issues or questions please contact us on Gitter.
Thanks

title: HOW-TO: Use environment variables
---

Sometimes you might want your test to make use of variables set on an environment-level. Common reasons for this include
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Sometimes you might want your test to make use of variables set on an environment-level. Common reasons for this include
Sometimes you might want your test to make use of variables set on an environment-level. Common reasons for this include:

@@ -0,0 +1,57 @@
---
description: How to work with global variables in Mocha tests
title: Mess with globals
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Mess with" is fun phrasing, but these days we're more ... cleaned up.

Suggested change
title: Mess with globals
title: Globals

---
Related issue [#1582](https://github.com/mochajs/mocha/issues/1582)

If your test messes with globals, a reasonable expectation is that you will clean up after yourself. This is not impossible in the case of `process.stdout.write()` or `console.log()`. In fact, it's pretty easy.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is just moving code over, but we shouldn't say things are "easy".

Suggested change
If your test messes with globals, a reasonable expectation is that you will clean up after yourself. This is not impossible in the case of `process.stdout.write()` or `console.log()`. In fact, it's pretty easy.
If your test manipulates globals, a reasonable expectation is that you will clean up after yourself. This includes commonly called methods such as `process.stdout.write()` or `console.log()`.

@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author waiting on response from OP or other posters - more information needed label Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for author waiting on response from OP or other posters - more information needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants