From fbceb19bbdad121f0100ec3434258775bd87aeaf Mon Sep 17 00:00:00 2001 From: Mark Wiemer <7833360+mark-wiemer@users.noreply.github.com> Date: Fri, 21 Mar 2025 08:33:46 -0700 Subject: [PATCH 1/6] docs: fix new website typos, improve readability (#5312) * Fix typos, improve readability * Cleanup decision tree intro --- .../src/content/docs/declaring/dynamic-tests.mdx | 4 ++-- .../content/docs/declaring/inclusive-tests.mdx | 4 ++-- .../src/content/docs/declaring/pending-tests.mdx | 2 +- .../content/docs/declaring/retrying-tests.mdx | 2 +- .../explainers/test-fixture-decision-tree.mdx | 2 +- .../src/content/docs/features/assertions.mdx | 2 +- .../content/docs/features/asynchronous-code.mdx | 4 ++-- docs-next/src/content/docs/features/hooks.mdx | 2 +- .../src/content/docs/features/parallel-mode.mdx | 5 ++--- .../content/docs/features/root-hook-plugins.mdx | 4 ++-- docs-next/src/content/docs/features/timeouts.mdx | 2 +- .../src/content/docs/reporters/markdown.mdx | 2 +- docs-next/src/content/docs/reporters/xunit.mdx | 3 +-- docs-next/src/content/docs/running/browsers.mdx | 2 +- docs-next/src/content/docs/running/cli.mdx | 16 +++++++++------- .../src/content/docs/running/configuring.mdx | 6 +++--- .../src/content/docs/running/test-globs.mdx | 2 +- 17 files changed, 32 insertions(+), 32 deletions(-) diff --git a/docs-next/src/content/docs/declaring/dynamic-tests.mdx b/docs-next/src/content/docs/declaring/dynamic-tests.mdx index f7deeb8b41..08b7425b8f 100644 --- a/docs-next/src/content/docs/declaring/dynamic-tests.mdx +++ b/docs-next/src/content/docs/declaring/dynamic-tests.mdx @@ -4,7 +4,7 @@ title: Dynamic Tests --- Given Mocha's use of function expressions to define suites and test cases, it's straightforward to generate your tests dynamically. -No special syntax is required — plain old JavaScript can be used to achieve functionality similar to "parameterized" tests, which you may have seen in other frameworks. +No special syntax is required--plain old JavaScript can be used to achieve functionality similar to "parameterized" tests, which you may have seen in other frameworks. Take the following example: @@ -77,7 +77,7 @@ const tests = await new Promise((resolve) => { ]); }); -// in suites ASYNCHRONOUS callbacks are NOT supported +// in suites, async callbacks are **not** supported describe("add()", function () { tests.forEach(({ args, expected }) => { it(`correctly adds ${args.length} args`, function () { diff --git a/docs-next/src/content/docs/declaring/inclusive-tests.mdx b/docs-next/src/content/docs/declaring/inclusive-tests.mdx index c4a4c989cf..056583be16 100644 --- a/docs-next/src/content/docs/declaring/inclusive-tests.mdx +++ b/docs-next/src/content/docs/declaring/inclusive-tests.mdx @@ -5,7 +5,7 @@ title: Inclusive Tests This feature is the inverse of `.only()`. By appending `.skip()`, you may tell Mocha to ignore test case(s). -Anything skipped will be marked as [pending](./pending-tests), and reported as such. +Anything skipped will be marked as [pending](./pending-tests) and reported as such. Here's an example of skipping an individual test: ```js @@ -36,7 +36,7 @@ describe("Array", function () { }); ``` -_Note_: Code in skipped suites, that is placed outside of hooks or tests is still executed, as mocha will still invoke the suite function to build up the suite structure for visualization. +_Note_: Code in skipped suites that is placed outside of hooks or tests is still executed, as Mocha will still invoke the suite function to build up the suite structure for visualization. :::tip[Best practice] Use `.skip()` instead of commenting tests out. diff --git a/docs-next/src/content/docs/declaring/pending-tests.mdx b/docs-next/src/content/docs/declaring/pending-tests.mdx index 295e755333..fbd0ac4a35 100644 --- a/docs-next/src/content/docs/declaring/pending-tests.mdx +++ b/docs-next/src/content/docs/declaring/pending-tests.mdx @@ -14,7 +14,7 @@ describe("Array", function () { }); ``` -Pending tests will be included in the test results, and marked as pending. +Pending tests will be included in the test results and marked as pending. A pending test is not considered a failed test. Read the [inclusive tests section](./inclusive-tests) for an example of conditionally marking a test as pending via `this.skip()`. diff --git a/docs-next/src/content/docs/declaring/retrying-tests.mdx b/docs-next/src/content/docs/declaring/retrying-tests.mdx index 7a71398cbd..a89b65fdf2 100644 --- a/docs-next/src/content/docs/declaring/retrying-tests.mdx +++ b/docs-next/src/content/docs/declaring/retrying-tests.mdx @@ -11,7 +11,7 @@ This feature does re-run a failed test and its corresponding `beforeEach/afterEa `this.retries()` has no effect on failing hooks. :::note -Example below was written using Selenium webdriver (which [overwrites global Mocha hooks](https://github.com/SeleniumHQ/selenium/blob/c10e8a955883f004452cdde18096d70738397788/javascript/node/selenium-webdriver/testing/index.js) for `Promise` chain). +The example below was written using Selenium webdriver (which [overwrites global Mocha hooks](https://github.com/SeleniumHQ/selenium/blob/c10e8a955883f004452cdde18096d70738397788/javascript/node/selenium-webdriver/testing/index.js) for `Promise` chain). ::: ```js diff --git a/docs-next/src/content/docs/explainers/test-fixture-decision-tree.mdx b/docs-next/src/content/docs/explainers/test-fixture-decision-tree.mdx index 4b90ba6fe0..82c9ee2036 100644 --- a/docs-next/src/content/docs/explainers/test-fixture-decision-tree.mdx +++ b/docs-next/src/content/docs/explainers/test-fixture-decision-tree.mdx @@ -3,7 +3,7 @@ description: Helping you decide which API(s) to use for your test fixtures. title: Test Fixture Decision Tree --- -This flowchart will help you decide which of [hooks](../features/hooks), [root hook plugins](../features/root-hook-plugins) or [global fixtures](../features/global-fixtures) you should use. +This flowchart will help you decide when to use [hooks](../features/hooks), [root hook plugins](../features/root-hook-plugins) or [global fixtures](../features/global-fixtures). import FixtureWizard from "../../../components/FixtureWizard.astro"; diff --git a/docs-next/src/content/docs/features/assertions.mdx b/docs-next/src/content/docs/features/assertions.mdx index 516ae49a5d..ec694ffe45 100644 --- a/docs-next/src/content/docs/features/assertions.mdx +++ b/docs-next/src/content/docs/features/assertions.mdx @@ -4,7 +4,7 @@ title: Assertions --- Mocha allows you to use any assertion library you wish. -In many of this site's examples, we're using Node.js' built-in [assert](https://nodejs.org/api/assert.html) module — but generally, if it throws an `Error`, it will work! +In many of this site's examples, we're using Node.js' built-in [assert](https://nodejs.org/api/assert.html) module--but generally, if it throws an `Error`, it will work! This means you can use libraries such as: - [better-assert](https://github.com/visionmedia/better-assert) - C-style self-documenting `assert()` diff --git a/docs-next/src/content/docs/features/asynchronous-code.mdx b/docs-next/src/content/docs/features/asynchronous-code.mdx index fdff81ab1b..83a95b4192 100644 --- a/docs-next/src/content/docs/features/asynchronous-code.mdx +++ b/docs-next/src/content/docs/features/asynchronous-code.mdx @@ -3,8 +3,8 @@ description: Testing asynchronous code with Mocha title: Asynchronous Code --- -By adding an argument (usually named `done`) to `it()` to a test callback, Mocha will know that it should wait for this function to be called to complete the test. -This callback accepts both an `Error` instance (or subclass thereof) _or_ a falsy value; anything else is invalid usage and throws an error (usually causing a failed test). +By adding an argument (usually named `done`) to a test callback, Mocha will know that it should wait for this function to be called to complete the test. +This callback accepts both an `Error` instance _or_ a falsy value; anything else is invalid usage and throws an error (usually causing a failed test). ```js describe("User", function () { diff --git a/docs-next/src/content/docs/features/hooks.mdx b/docs-next/src/content/docs/features/hooks.mdx index 062827d432..895856f001 100644 --- a/docs-next/src/content/docs/features/hooks.mdx +++ b/docs-next/src/content/docs/features/hooks.mdx @@ -30,7 +30,7 @@ describe("hooks", function () { :::note Tests can appear before, after, or interspersed with your hooks. -Hooks will run in the order they are defined, as appropriate; all `before()` hooks run (once), then any `beforeEach()` hooks, tests, any `afterEach()` hooks, and finally `after()` hooks (once). +Hooks will run in the order they are defined, as appropriate: all `before()` hooks run (once), then any `beforeEach()` hooks, tests, any `afterEach()` hooks, and finally `after()` hooks (once). ::: ## Describing Hooks diff --git a/docs-next/src/content/docs/features/parallel-mode.mdx b/docs-next/src/content/docs/features/parallel-mode.mdx index 8a6a53fe9a..24a514aa5b 100644 --- a/docs-next/src/content/docs/features/parallel-mode.mdx +++ b/docs-next/src/content/docs/features/parallel-mode.mdx @@ -112,8 +112,7 @@ Here are a couple suggested workarounds: 1. `require('./setup.js')` or `import './setup.js'` at the top of every test file. Best avoided for those averse to boilerplate. -1. _Recommended_: Define root hooks in a "required" file, using the new (also as - of v8.0.0) [Root Hook Plugin](./root-hook-plugins) system. +1. _Recommended_: Define root hooks in a "required" file, using the [Root Hook Plugin](./root-hook-plugins) system. If you need to run some code _once and only once_, use a [global fixture](./global-fixtures) instead. @@ -133,7 +132,7 @@ If you find your tests don't work properly when run with [`--parallel`](../runni - ✅ Ensure you are using a [supported reporter](#reporter-limitations). - ✅ Ensure you are not using [other unsupported flags](#file-order-is-non-deterministic). - ✅ Double-check your [config file](../running/configuring); options set in config files will be merged with any command-line option. -- ✅ Look for root hooks (they look like [this](#root-hooks-are-not-global)) in your tests. +- ✅ Look for [root hooks](#root-hooks-are-not-global) in your tests. Move them into a [Root Hook Plugin](./root-hook-plugins). - ✅ Do any assertion, mock, or other test libraries you're consuming use root hooks? They may need to be [migrated](#migrating-a-library-to-use-root-hook-plugins) for compatibility with parallel mode. - ✅ If tests are unexpectedly timing out, you may need to increase the default test timeout (via [`--timeout`](../running/cli#--timeout-ms--t-ms)) diff --git a/docs-next/src/content/docs/features/root-hook-plugins.mdx b/docs-next/src/content/docs/features/root-hook-plugins.mdx index c1d82bc488..564b55daa4 100644 --- a/docs-next/src/content/docs/features/root-hook-plugins.mdx +++ b/docs-next/src/content/docs/features/root-hook-plugins.mdx @@ -14,7 +14,7 @@ For that reason, running root hooks using this method is _strongly discouraged_, A _Root Hook Plugin_ is a JavaScript file loaded via [`--require`](../running/cli#--require-module--r-module) which "registers" one or more root hooks to be used across all test files. -In browsers you can set root hooks directly via a `rootHooks` object: `mocha.setup({ rootHooks: {beforeEach() {...}} })`, see [`mocha.setup()`](../running/browsers) +In browsers you can set root hooks directly via a `rootHooks` object: `mocha.setup({ rootHooks: { beforeEach() {...} } })`, see [`mocha.setup()`](../running/browsers) ## Defining a Root Hook Plugin @@ -208,7 +208,7 @@ Your `test/hooks.js` (for this example, a CJS module) should contain: // test/hooks.js exports.mochaHooks = { - beforeEach: function () { + beforeAll: function () { // global setup for all tests }, afterAll: function () { diff --git a/docs-next/src/content/docs/features/timeouts.mdx b/docs-next/src/content/docs/features/timeouts.mdx index e29680e7c4..4c28da72a4 100644 --- a/docs-next/src/content/docs/features/timeouts.mdx +++ b/docs-next/src/content/docs/features/timeouts.mdx @@ -64,7 +64,7 @@ With async tests if you disable timeouts via `this.timeout(0)` and then do not c ## Diffs Mocha supports the `err.expected` and `err.actual` properties of any thrown `AssertionError`s from an assertion library. -Mocha will attempt to display the difference between what was expected, and what the assertion actually saw. +Mocha will attempt to display the difference between what was expected and what the assertion actually saw. Here's an example of a "string" diff using `--inline-diffs`: ![string diffs](./reporter-string-diffs.png) diff --git a/docs-next/src/content/docs/reporters/markdown.mdx b/docs-next/src/content/docs/reporters/markdown.mdx index 3def0894d5..301e72a891 100644 --- a/docs-next/src/content/docs/reporters/markdown.mdx +++ b/docs-next/src/content/docs/reporters/markdown.mdx @@ -6,5 +6,5 @@ title: Markdown Alias: `Markdown`, `markdown` The Markdown reporter generates a markdown TOC and body for your test suite. -This is great if you want to use the tests as documentation within a Github wiki page, or a markdown file in the repository that Github can render. +This is great if you want to use the tests as documentation within a GitHub wiki page, or a markdown file in the repository that GitHub can render. For example, here is the Connect [test output](https://github.com/senchalabs/connect/blob/90a725343c2945aaee637e799b1cd11e065b2bff/tests.md). diff --git a/docs-next/src/content/docs/reporters/xunit.mdx b/docs-next/src/content/docs/reporters/xunit.mdx index 47b3306300..ce53ac1961 100644 --- a/docs-next/src/content/docs/reporters/xunit.mdx +++ b/docs-next/src/content/docs/reporters/xunit.mdx @@ -5,8 +5,7 @@ title: XUnit Alias: `XUnit`, `xunit` -The XUnit reporter is also available. -It outputs an XUnit-compatible XML document, often applicable in CI servers. +The XUnit reporter outputs an XUnit-compatible XML document, often applicable in CI servers. By default, it will output to the console. To write directly to a file, use `--reporter-option output=filename.xml`. diff --git a/docs-next/src/content/docs/running/browsers.mdx b/docs-next/src/content/docs/running/browsers.mdx index 124dafe522..f9232ba472 100644 --- a/docs-next/src/content/docs/running/browsers.mdx +++ b/docs-next/src/content/docs/running/browsers.mdx @@ -3,7 +3,7 @@ description: Running Mocha in Browsers title: Browsers --- -Mocha runs in the browser. +Mocha can run in the browser. Every release of Mocha will have new builds of `./mocha.js` and `./mocha.css` for use in the browser. A typical setup might look something like the following, where we call `mocha.setup('bdd')` to use the **BDD** interface before loading the test scripts, running them `onload` with `mocha.run()`. diff --git a/docs-next/src/content/docs/running/cli.mdx b/docs-next/src/content/docs/running/cli.mdx index e3079d3bcc..4f25ca9538 100644 --- a/docs-next/src/content/docs/running/cli.mdx +++ b/docs-next/src/content/docs/running/cli.mdx @@ -5,6 +5,8 @@ description: Running Mocha in your terminal. Running `npx mocha --help` will show the full list of available commands: +{/* This output is defined in lib/cli/run.js */} + ```plaintext mocha [spec..] @@ -154,7 +156,7 @@ TL;DR: If your tests hang after an upgrade to Mocha v4.0.0 or newer, use `--exit ::: _Prior to_ version v4.0.0, _by default_, Mocha would force its own process to exit once it was finished executing all tests. -This behavior enables a set of potential problems; it's indicative of tests (or fixtures, harnesses, code under test, etc.) which don't clean up after themselves properly. +This behavior enables a set of potential problems: it's indicative of tests (or fixtures, harnesses, code under test, etc.) which don't clean up after themselves properly. Ultimately, "dirty" tests can (but not always) lead to _false positive_ or _false negative_ results. "Hanging" most often manifests itself if a server is still listening on a port, or a socket is still open, etc. @@ -163,7 +165,7 @@ It can also be something like a runaway `setInterval()`, or even an errant `Prom The _default behavior_ in v4.0.0 (and newer) is `--no-exit`, where previously it was `--exit`. **The easiest way to "fix" the issue is to pass `--exit` to the Mocha process.** -It _can_ be time-consuming to debug — because it's not always obvious where the problem is — but it _is_ recommended to do so. +It _can_ be time-consuming to debug--because it's not always obvious where the problem is--but it _is_ recommended to do so. To ensure your tests aren't leaving messes around, here are some ideas to get started: @@ -184,7 +186,7 @@ If set to `true`, Mocha returns exit code `0` even if there are failed tests dur :::note[New in v9.1.0] ::: -Fail test run if no tests are encountered with `exit-code: 1`. +Fail test run with `exit-code: 1` if no tests are encountered. ### `--forbid-only` @@ -478,7 +480,7 @@ Rerun tests on file changes. The `--watch-files` and `--watch-ignore` options can be used to control which files are watched for changes. -Tests may be rerun manually by typing ⓡ ⓢ ⏎ (same shortcut as `nodemon`). +Tests may be rerun manually by typing `rs` and pressing enter (same shortcut as `nodemon`). ### `--watch-files ` @@ -535,7 +537,7 @@ The same goes for any other part of a suite or test-case title, `--grep users` w And another option with double quotes: `--grep "groupA|groupB"`. And for more complex criteria: `--grep "/get/i"`. -Some shells as e.g. Git-Bash-for-Windows may require: `--grep "'/get/i'"`. +Some shells (e.g. Git Bash for Windows) may require: `--grep "'/get/i'"`. Using flags other than the `ignoreCase /i` (especially `/g` and `/y`) may lead to unpredictable results. ```js @@ -602,7 +604,7 @@ You can also pass `node` flags to Node.js using [`--node-option`](#--node-option ### `--enable-source-maps` -:::note[New in vNode.js v12.12.0] +:::note[New in Node.js v12.12.0] ::: If the [`--enable-source-maps`](https://nodejs.org/dist/latest-v12.x/docs/api/cli.html#cli_enable_source_maps) flag @@ -618,7 +620,7 @@ Error: cool Prepend `--v8-` to any flag listed in the output of `node --v8-options` (excluding `--v8-options` itself) to use it. -V8 flags can be defined in Mocha's [configuration](./configuring). +[V8](https://v8.dev/) flags can be defined in Mocha's [configuration](./configuring). :::note[New in v9.1.0] You can also pass V8 flags (without `--v8-`) to Node.js using [`--node-option`](#--node-option-name--n-name). diff --git a/docs-next/src/content/docs/running/configuring.mdx b/docs-next/src/content/docs/running/configuring.mdx index 99d7415928..448164da6e 100644 --- a/docs-next/src/content/docs/running/configuring.mdx +++ b/docs-next/src/content/docs/running/configuring.mdx @@ -12,7 +12,7 @@ Mocha supports configuration files, typical of modern command-line tools, in sev in your project's root directory, and export an object (`module.exports = {/* ... */}`) containing your configuration. - **YAML**: Create a `.mocharc.yaml` (or `.mocharc.yml`) in your project's root directory. - **JSON**: Create a `.mocharc.json` (or `.mocharc.jsonc`) in your project's root directory. - Comments — while not valid JSON — are allowed in this file, and will be ignored by Mocha. + Comments--while not valid JSON--are allowed in this file, and will be ignored by Mocha. - **package.json**: Create a `mocha` property in your project's `package.json`. ## Custom Locations @@ -29,7 +29,7 @@ Likewise, use `--no-package` to stop Mocha from looking for configuration in a ` ## Priorities -If no custom path was given, and if there are multiple configuration files in the same directory, Mocha will search for — and use — only one. +If no custom path was given, and if there are multiple configuration files in the same directory, Mocha will search for--and use--only one. The priority is: 1. `.mocharc.js` @@ -65,7 +65,7 @@ For example, a `.mocharc.json` containing `"require": "bar"`, coupled with execu ## Extending Configuration Configurations can inherit from other modules using the `extends` keyword. -See [here](http://yargs.js.org/docs/#api-reference-configobject-extends-keyword) for more information. +See [yargs API reference](http://yargs.js.org/docs/#api-reference-configobject-extends-keyword) for more information. ## Configuration Format diff --git a/docs-next/src/content/docs/running/test-globs.mdx b/docs-next/src/content/docs/running/test-globs.mdx index cb7800c12f..8ba21f6d53 100644 --- a/docs-next/src/content/docs/running/test-globs.mdx +++ b/docs-next/src/content/docs/running/test-globs.mdx @@ -24,6 +24,6 @@ You should _always_ quote your globs in npm scripts. If you use quotes, the [`glob`](https://www.npmjs.com/package/glob) module will handle its expansion. For maximum compatibility, surround the entire expression with double quotes and refrain from `$`, `"`, `^`, and `\` within your expression. -See this [tutorial](https://gist.github.com/reggi/475793ea1846affbcfe8) on using globs. +See this [tutorial on using globs](https://gist.github.com/reggi/475793ea1846affbcfe8). _Note_: Double quotes around the glob are recommended for portability. From 3a46855294f82e58a5a414aed3525e394b82aced Mon Sep 17 00:00:00 2001 From: Mark Wiemer <7833360+mark-wiemer@users.noreply.github.com> Date: Thu, 27 Mar 2025 05:22:23 -0700 Subject: [PATCH 2/6] chore: "force" Netlify to use npm to build new site (#5319) * docs: add new website using Astro Starlight * chore: add docs command to package.json * Add supporters.js dependencies * add root-level install to npm run docs * remove question mark * docs-next/netlify.toml * console.log(process.env) * Don't have /next base in Netlify * More proper astro.config.mjs * linting * Smaller title * Dark mode fixups * Slightly darker sl-color-white * Mentioned this being WIP * Missing _ * Tweaked notice * Tweaked notice colors * Tweaked notice text * fix /api and /example/tests.html links * fix: responsive homepage title * fix: sized responsive homepage title * Added override for mocha-thumbnail.svg * Added starting buttons * fix: starting buttons config link * fix: starting buttons 'ing' * Footer mobile responsiveness, and root netlify.toml revert * Simpler, more accurate test file * Use npm explicitly * Remove pnpm-lock.yaml * Remove example.mdx --------- Co-authored-by: Josh Goldberg --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index de6ee3cee3..6505a3cfd9 100644 --- a/package.json +++ b/package.json @@ -204,5 +204,6 @@ }, "overrides": { "webdriverio": "^7.33.0" - } + }, + "packageManager": "npm@10.9.2+sha512.8ab88f10f224a0c614cb717a7f7c30499014f77134120e9c1f0211ea3cf3397592cbe483feb38e0c4b3be1c54e347292c76a1b5edb94a3289d5448484ab8ac81" } From 18699a0d668ed2654dd15433f03b74348baf9559 Mon Sep 17 00:00:00 2001 From: Mark Wiemer <7833360+mark-wiemer@users.noreply.github.com> Date: Mon, 31 Mar 2025 09:39:50 -0700 Subject: [PATCH 3/6] chore: Fix tests (#5320) * Run main workflow on command * test commit * Test push * test commit 3 * test commit 4 * Try 20.18.3 for Ubuntu --- .github/workflows/mocha.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mocha.yml b/.github/workflows/mocha.yml index 5e5add003a..02e9d2770a 100644 --- a/.github/workflows/mocha.yml +++ b/.github/workflows/mocha.yml @@ -9,6 +9,7 @@ on: branches: - main paths-ignore: ['*.md', 'docs/**'] + workflow_dispatch: permissions: contents: read @@ -65,8 +66,9 @@ jobs: coverage: false with: os: 'ubuntu-latest,windows-latest' + # The 20.18.3 is instead of 20 per https://github.com/mochajs/mocha/issues/5052 # The 22.11.0 is instead of 22 per https://github.com/mochajs/mocha/issues/5278 - node-versions: '18,20,22.11.0' + node-versions: '18,20.18.3,22.11.0' npm-script: test-node:${{ matrix.test-part }} coverage: ${{ matrix.coverage }} From 1a0caf6b653d39b9fb09cde6ee1e92a075be8f4b Mon Sep 17 00:00:00 2001 From: Mark Wiemer <7833360+mark-wiemer@users.noreply.github.com> Date: Mon, 7 Apr 2025 10:23:49 -0700 Subject: [PATCH 4/6] Revert "chore: "force" Netlify to use npm to build new site (#5319)" (#5322) This reverts commit 3a46855294f82e58a5a414aed3525e394b82aced. --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 6505a3cfd9..de6ee3cee3 100644 --- a/package.json +++ b/package.json @@ -204,6 +204,5 @@ }, "overrides": { "webdriverio": "^7.33.0" - }, - "packageManager": "npm@10.9.2+sha512.8ab88f10f224a0c614cb717a7f7c30499014f77134120e9c1f0211ea3cf3397592cbe483feb38e0c4b3be1c54e347292c76a1b5edb94a3289d5448484ab8ac81" + } } From 7c08d0944d2255084bc4415238430b13c90f0df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Thu, 10 Apr 2025 06:43:11 -0500 Subject: [PATCH 5/6] fix: switch from ansi-colors to picocolors (#5323) --- lib/cli/cli.js | 12 ++++----- lib/cli/collect-files.js | 6 ++--- lib/cli/options.js | 4 +-- lib/cli/run-helpers.js | 4 +-- lib/cli/run.js | 4 +-- package-lock.json | 53 +++++++++------------------------------- package.json | 2 +- 7 files changed, 28 insertions(+), 57 deletions(-) diff --git a/lib/cli/cli.js b/lib/cli/cli.js index 9b0d2ec024..6229335d85 100755 --- a/lib/cli/cli.js +++ b/lib/cli/cli.js @@ -20,7 +20,7 @@ const { } = require('./options'); const lookupFiles = require('./lookup-files'); const commands = require('./commands'); -const ansi = require('ansi-colors'); +const pc = require('picocolors'); const {repository, homepage, version, discord} = require('../../package.json'); const {cwd} = require('../utils'); @@ -60,7 +60,7 @@ exports.main = (argv = process.argv.slice(2), mochaArgs) => { .fail((msg, err, yargs) => { debug('caught error sometime before command handler: %O', err); yargs.showHelp(); - console.error(`\n${symbols.error} ${ansi.red('ERROR:')} ${msg}`); + console.error(`\n${symbols.error} ${pc.red('ERROR:')} ${msg}`); process.exit(1); }) .help('help', 'Show usage information & exit') @@ -69,10 +69,10 @@ exports.main = (argv = process.argv.slice(2), mochaArgs) => { .alias('version', 'V') .wrap(process.stdout.columns ? Math.min(process.stdout.columns, 80) : 80) .epilog( - `${ansi.reset("Mocha Resources")} - Chat: ${ansi.magenta(discord)} - GitHub: ${ansi.blue(repository.url)} - Docs: ${ansi.yellow(homepage)} + `${pc.reset("Mocha Resources")} + Chat: ${pc.magenta(discord)} + GitHub: ${pc.blue(repository.url)} + Docs: ${pc.yellow(homepage)} ` ) .parserConfiguration(YARGS_PARSER_CONFIG) diff --git a/lib/cli/collect-files.js b/lib/cli/collect-files.js index 14503c0431..181b64a540 100644 --- a/lib/cli/collect-files.js +++ b/lib/cli/collect-files.js @@ -2,7 +2,7 @@ const fs = require('node:fs'); const path = require('node:path'); -const ansi = require('ansi-colors'); +const pc = require('picocolors'); const debug = require('debug')('mocha:cli:run:helpers'); const minimatch = require('minimatch'); const {NO_FILES_MATCH_PATTERN} = require('../errors').constants; @@ -94,12 +94,12 @@ module.exports = ({ unmatchedSpecFiles[0].pattern )}` // stringify to print escaped characters raw : 'Error: No test files found'; - console.error(ansi.red(noneFoundMsg)); + console.error(pc.red(noneFoundMsg)); process.exit(1); } else { // print messages as a warning unmatchedSpecFiles.forEach(warning => { - console.warn(ansi.yellow(`Warning: ${warning.message}`)); + console.warn(pc.yellow(`Warning: ${warning.message}`)); }); } diff --git a/lib/cli/options.js b/lib/cli/options.js index 825d535db4..167c78de69 100644 --- a/lib/cli/options.js +++ b/lib/cli/options.js @@ -8,7 +8,7 @@ */ const fs = require('node:fs'); -const ansi = require('ansi-colors'); +const pc = require('picocolors'); const yargsParser = require('yargs-parser'); const { types, @@ -180,7 +180,7 @@ const parse = (args = [], defaultValues = {}, ...configObjects) => { boolean: types.boolean.concat(nodeArgs.map(pair => pair[0])) }); if (result.error) { - console.error(ansi.red(`Error: ${result.error.message}`)); + console.error(pc.red(`Error: ${result.error.message}`)); process.exit(1); } diff --git a/lib/cli/run-helpers.js b/lib/cli/run-helpers.js index 440965df31..a7e631b778 100644 --- a/lib/cli/run-helpers.js +++ b/lib/cli/run-helpers.js @@ -9,7 +9,7 @@ const fs = require('node:fs'); const path = require('node:path'); -const ansi = require('ansi-colors'); +const pc = require('picocolors'); const debug = require('debug')('mocha:cli:run:helpers'); const {watchRun, watchParallelRun} = require('./watch-run'); const collectFiles = require('./collect-files'); @@ -121,7 +121,7 @@ const handleUnmatchedFiles = (mocha, unmatchedFiles) => { unmatchedFiles.forEach(({pattern, absolutePath}) => { console.error( - ansi.yellow( + pc.yellow( `Warning: Cannot find any files matching pattern "${pattern}" at the absolute path "${absolutePath}"` ) ); diff --git a/lib/cli/run.js b/lib/cli/run.js index 0e2ab512ca..5f42c5082b 100644 --- a/lib/cli/run.js +++ b/lib/cli/run.js @@ -8,7 +8,7 @@ */ const symbols = require('log-symbols'); -const ansi = require('ansi-colors'); +const pc = require('picocolors'); const Mocha = require('../mocha'); const { createUnsupportedError, @@ -357,7 +357,7 @@ exports.builder = yargs => Object.assign(argv, plugins); } catch (err) { // this could be a bad --require, bad reporter, ui, etc. - console.error(`\n${symbols.error} ${ansi.red('ERROR:')}`, err); + console.error(`\n${symbols.error} ${pc.red('ERROR:')}`, err); yargs.exit(1); } }) diff --git a/package-lock.json b/package-lock.json index bd0efefe52..0b42e2f161 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,6 @@ "version": "11.2.0", "license": "MIT", "dependencies": { - "ansi-colors": "^4.1.3", "browser-stdout": "^1.3.1", "chokidar": "^3.5.3", "debug": "^4.3.5", @@ -22,6 +21,7 @@ "log-symbols": "^4.1.0", "minimatch": "^5.1.6", "ms": "^2.1.3", + "picocolors": "^1.1.1", "serialize-javascript": "^6.0.2", "strip-json-comments": "^3.1.1", "supports-color": "^8.1.1", @@ -2279,14 +2279,6 @@ "ajv": "^6.9.1" } }, - "node_modules/ansi-colors": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", - "engines": { - "node": ">=6" - } - }, "node_modules/ansi-red": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz", @@ -9170,13 +9162,6 @@ "typescript": ">=5.0.4" } }, - "node_modules/knip/node_modules/picocolors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", - "integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==", - "dev": true, - "license": "ISC" - }, "node_modules/knip/node_modules/picomatch": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", @@ -11966,6 +11951,12 @@ "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", "dev": true }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -15422,12 +15413,6 @@ "browserslist": ">= 4.21.0" } }, - "node_modules/update-browserslist-db/node_modules/picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true - }, "node_modules/upper-case-first": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz", @@ -18005,11 +17990,6 @@ "dev": true, "requires": {} }, - "ansi-colors": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==" - }, "ansi-red": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz", @@ -23300,12 +23280,6 @@ "zod-validation-error": "^3.0.3" }, "dependencies": { - "picocolors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", - "integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==", - "dev": true - }, "picomatch": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", @@ -25377,6 +25351,11 @@ "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", "dev": true }, + "picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==" + }, "picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -28057,14 +28036,6 @@ "requires": { "escalade": "^3.1.1", "picocolors": "^1.0.0" - }, - "dependencies": { - "picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", - "dev": true - } } }, "upper-case-first": { diff --git a/package.json b/package.json index de6ee3cee3..aabae85e31 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,6 @@ "version": "run-p version:* && git add -A ./AUTHORS ./CHANGELOG.md" }, "dependencies": { - "ansi-colors": "^4.1.3", "browser-stdout": "^1.3.1", "chokidar": "^3.5.3", "debug": "^4.3.5", @@ -107,6 +106,7 @@ "log-symbols": "^4.1.0", "minimatch": "^5.1.6", "ms": "^2.1.3", + "picocolors": "^1.1.1", "serialize-javascript": "^6.0.2", "strip-json-comments": "^3.1.1", "supports-color": "^8.1.1", From 0d09939fa9b710398a14e936dd02d3b5a7a478c2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 10 Apr 2025 07:55:05 -0400 Subject: [PATCH 6/6] chore(main): release 11.2.1 (#5316) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .github/release-please/manifest.json | 2 +- CHANGELOG.md | 18 ++++++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.github/release-please/manifest.json b/.github/release-please/manifest.json index d0151d6895..8059fb1e27 100644 --- a/.github/release-please/manifest.json +++ b/.github/release-please/manifest.json @@ -1 +1 @@ -{".":"11.2.0"} +{".":"11.2.1"} diff --git a/CHANGELOG.md b/CHANGELOG.md index 244e4f771a..8e1bc986ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## [11.2.1](https://github.com/mochajs/mocha/compare/v11.2.0...v11.2.1) (2025-04-10) + + +### 🩹 Fixes + +* switch from ansi-colors to picocolors ([#5323](https://github.com/mochajs/mocha/issues/5323)) ([7c08d09](https://github.com/mochajs/mocha/commit/7c08d0944d2255084bc4415238430b13c90f0df5)) + + +### 📚 Documentation + +* fix new website typos, improve readability ([#5312](https://github.com/mochajs/mocha/issues/5312)) ([fbceb19](https://github.com/mochajs/mocha/commit/fbceb19bbdad121f0100ec3434258775bd87aeaf)) + + +### 🧹 Chores + +* "force" Netlify to use npm to build new site ([#5319](https://github.com/mochajs/mocha/issues/5319)) ([3a46855](https://github.com/mochajs/mocha/commit/3a46855294f82e58a5a414aed3525e394b82aced)) +* Fix tests ([#5320](https://github.com/mochajs/mocha/issues/5320)) ([18699a0](https://github.com/mochajs/mocha/commit/18699a0d668ed2654dd15433f03b74348baf9559)) + ## [11.2.0](https://github.com/mochajs/mocha/compare/v11.1.0...v11.2.0) (2025-03-17) diff --git a/package-lock.json b/package-lock.json index 0b42e2f161..3e363e5144 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mocha", - "version": "11.2.0", + "version": "11.2.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mocha", - "version": "11.2.0", + "version": "11.2.1", "license": "MIT", "dependencies": { "browser-stdout": "^1.3.1", diff --git a/package.json b/package.json index aabae85e31..67db651d1e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mocha", - "version": "11.2.0", + "version": "11.2.1", "type": "commonjs", "description": "simple, flexible, fun test framework", "keywords": [