From a2e600d70f4d7ca6ba8741ebe8c70cfec438ef1b Mon Sep 17 00:00:00 2001 From: Lucas Lopes Date: Fri, 8 Mar 2024 10:14:57 -0300 Subject: [PATCH 01/34] fix: closes #5115 (#5116) Eleventy wasn't being able to parse the JSDocs for the returned type on the getFullErrorStack function. Defining it as a new type and then referencing it on the function fixes the issue --- lib/reporters/base.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/reporters/base.js b/lib/reporters/base.js index 5af6e7bd8a..e0ca5f4863 100644 --- a/lib/reporters/base.js +++ b/lib/reporters/base.js @@ -227,7 +227,7 @@ var generateDiff = (exports.generateDiff = function (actual, expected) { * @private * @param {Error} err * @param {Set} [seen] - * @return {{ message: string, msg: string, stack: string }} + * @return {FullErrorStack} */ var getFullErrorStack = function (err, seen) { if (seen && seen.has(err)) { @@ -580,3 +580,12 @@ function sameType(a, b) { Base.consoleLog = consoleLog; Base.abstract = true; + +/** + * An object with all stack traces recursively mounted from each err.cause + * @memberof module:lib/reporters/base + * @typedef {Object} FullErrorStack + * @property {string} message + * @property {string} msg + * @property {string} stack + */ From efbb147590dfd7ff290de40a9930b07334784054 Mon Sep 17 00:00:00 2001 From: Bryan Mishkin <698306+bmish@users.noreply.github.com> Date: Tue, 12 Mar 2024 23:08:19 +0800 Subject: [PATCH 02/34] feat: add file path to xunit reporter (#4985) * feat: add file path to xunit reporter * Update lib/reporters/xunit.js Co-authored-by: Ville Lahdenvuo * Revert "Update lib/reporters/xunit.js" This reverts commit 1245e7e80f3d9faed99d459dcfebdb35d31be370. --------- Co-authored-by: Ville Lahdenvuo --- lib/reporters/xunit.js | 1 + test/reporters/xunit.spec.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/reporters/xunit.js b/lib/reporters/xunit.js index ec788c5da0..4e6fe2bcf9 100644 --- a/lib/reporters/xunit.js +++ b/lib/reporters/xunit.js @@ -158,6 +158,7 @@ XUnit.prototype.test = function (test) { var attrs = { classname: test.parent.fullTitle(), name: test.title, + file: test.file, time: test.duration / 1000 || 0 }; diff --git a/test/reporters/xunit.spec.js b/test/reporters/xunit.spec.js index a5e0f1bbeb..4e98cf6002 100644 --- a/test/reporters/xunit.spec.js +++ b/test/reporters/xunit.spec.js @@ -30,6 +30,7 @@ describe('XUnit reporter', function () { var expectedLine = 'some-line'; var expectedClassName = 'fullTitle'; var expectedTitle = 'some title'; + var expectedFile = 'testFile.spec.js'; var expectedMessage = 'some message'; var expectedDiff = '\n + expected - actual\n\n -foo\n +bar\n '; @@ -325,6 +326,7 @@ describe('XUnit reporter', function () { var expectedTest = { state: STATE_FAILED, title: expectedTitle, + file: expectedFile, parent: { fullTitle: function () { return expectedClassName; @@ -347,6 +349,8 @@ describe('XUnit reporter', function () { expectedClassName + '" name="' + expectedTitle + + '" file="' + + expectedFile + '" time="1">' + expectedMessage + '\n' + @@ -365,6 +369,7 @@ describe('XUnit reporter', function () { var expectedTest = { state: STATE_FAILED, title: expectedTitle, + file: expectedFile, parent: { fullTitle: function () { return expectedClassName; @@ -402,6 +407,7 @@ describe('XUnit reporter', function () { return true; }, title: expectedTitle, + file: expectedFile, parent: { fullTitle: function () { return expectedClassName; @@ -418,6 +424,8 @@ describe('XUnit reporter', function () { expectedClassName + '" name="' + expectedTitle + + '" file="' + + expectedFile + '" time="1">'; expect(expectedWrite, 'to be', expectedTag); }); @@ -431,6 +439,7 @@ describe('XUnit reporter', function () { return false; }, title: expectedTitle, + file: expectedFile, parent: { fullTitle: function () { return expectedClassName; @@ -447,6 +456,8 @@ describe('XUnit reporter', function () { expectedClassName + '" name="' + expectedTitle + + '" file="' + + expectedFile + '" time="0"/>'; expect(expectedWrite, 'to be', expectedTag); }); From a5b565289b40a839af086b13fb369e04e205ed4b Mon Sep 17 00:00:00 2001 From: Nathan Phillip Brink Date: Tue, 12 Mar 2024 13:18:58 -0400 Subject: [PATCH 03/34] docs: fix documentation concerning glob expansion on UNIX (#4869) --- docs/index.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/index.md b/docs/index.md index b6a70eba7c..a56b64adde 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2257,10 +2257,11 @@ Some shells support recursive matching by using the globstar (`**`) wildcard. Ba $ mocha "./spec/**/*.js" ``` -[You should _always_ quote your globs in npm scripts][article-globbing]. If you -use double quotes, it's the shell on UNIX that will expand the glob. On the -other hand, if you use single quotes, the [`node-glob`][npm-glob] module will -handle its expansion. +You should _always_ quote your globs in npm scripts. If you +use quotes, the [`node-glob`][npm-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][gist-globbing-tutorial] on using globs. @@ -2352,7 +2353,6 @@ For a running example of Mocha, view [example/tests.html](example/tests.html). F or the [source](https://github.com/mochajs/mocha/blob/master/lib/mocha.js). [//]: # 'Cross reference section' -[article-globbing]: https://medium.com/@jakubsynowiec/you-should-always-quote-your-globs-in-npm-scripts-621887a2a784 [bash-globbing]: https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html [better-assert]: https://github.com/visionmedia/better-assert [caniuse-notifications]: https://caniuse.com/#feat=notifications From 6f3f45e587a17463b75047631152429fa14b82a3 Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Tue, 26 Mar 2024 18:00:32 +0100 Subject: [PATCH 04/34] fix: xunit integration test (#5122) --- test/integration/reporters.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/reporters.spec.js b/test/integration/reporters.spec.js index cdc15b8233..08fa7f85a3 100644 --- a/test/integration/reporters.spec.js +++ b/test/integration/reporters.spec.js @@ -44,8 +44,8 @@ describe('reporters', function () { 'output=' + tmpFile ]; var expectedOutput = [ - ' * Fix minor typo. * Update lib/cli/run.js Do not change the original functionality. Co-authored-by: Pelle Wessman * Check that the toString method is available on the error. * Opting for a simplified solution * Fix tests --------- Co-authored-by: Pelle Wessman --- lib/cli/run.js | 2 +- test/integration/reporters.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cli/run.js b/lib/cli/run.js index fbbe510e94..66c8cbbb66 100644 --- a/lib/cli/run.js +++ b/lib/cli/run.js @@ -369,7 +369,7 @@ exports.handler = async function (argv) { try { await runMocha(mocha, argv); } catch (err) { - console.error('\n' + (err.stack || `Error: ${err.message || err}`)); + console.error('\n Exception during run:', err); process.exit(1); } }; diff --git a/test/integration/reporters.spec.js b/test/integration/reporters.spec.js index 08fa7f85a3..9285dfe80c 100644 --- a/test/integration/reporters.spec.js +++ b/test/integration/reporters.spec.js @@ -211,7 +211,7 @@ describe('reporters', function () { return; } - var pattern = `^Error: invalid or unsupported TAP version: "${invalidTapVersion}"`; + var pattern = `Error: invalid or unsupported TAP version: "${invalidTapVersion}"`; expect(res, 'to satisfy', { code: 1, output: new RegExp(pattern, 'm') From 7a2781c17d4924c620ce5b31c4aab6c88bed72ef Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Tue, 26 Mar 2024 18:18:05 +0100 Subject: [PATCH 06/34] chore: activate dependabot for workflows (#5123) Related to #5055 --- .github/dependabot.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..7220d99409 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: 'github-actions' + directory: '/' + schedule: + interval: 'weekly' + groups: + github-actions: + patterns: + - '*' From 7ac67f3735b1ba6b1e1565ab9136d83c50f58abf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Mar 2024 18:27:15 +0100 Subject: [PATCH 07/34] build(deps): bump the github-actions group with 2 updates (#5125) Bumps the github-actions group with 2 updates: [actions/cache](https://github.com/actions/cache) and [buildsville/add-remove-label](https://github.com/buildsville/add-remove-label). Updates `actions/cache` from 3 to 4 - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3...v4) Updates `buildsville/add-remove-label` from 2.0.0 to 2.0.1 - [Release notes](https://github.com/buildsville/add-remove-label/releases) - [Commits](https://github.com/buildsville/add-remove-label/compare/v2.0.0...v2.0.1) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: buildsville/add-remove-label dependency-type: direct:production update-type: version-update:semver-patch dependency-group: github-actions ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/browser-test.yml | 4 ++-- .github/workflows/mocha.yml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/browser-test.yml b/.github/workflows/browser-test.yml index a037f6cc56..890769437f 100644 --- a/.github/workflows/browser-test.yml +++ b/.github/workflows/browser-test.yml @@ -20,7 +20,7 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} persist-credentials: false - name: 'Cache node_modules' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: '~/.npm' key: "ubuntu-latest-node-full-lts-${{ hashFiles('**/package-lock.json') }}" @@ -32,7 +32,7 @@ jobs: SAUCE_USERNAME: '${{secrets.SAUCE_USERNAME}}' SAUCE_ACCESS_KEY: '${{secrets.SAUCE_ACCESS_KEY}}' - name: remove 'run-browser-test' label - uses: buildsville/add-remove-label@v2.0.0 + uses: buildsville/add-remove-label@v2.0.1 if: ${{ always() }} with: token: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/mocha.yml b/.github/workflows/mocha.yml index a71d47804e..33e357fd9a 100644 --- a/.github/workflows/mocha.yml +++ b/.github/workflows/mocha.yml @@ -70,7 +70,7 @@ jobs: with: persist-credentials: false - name: 'Cache node_modules' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: '~/.npm' key: "ubuntu-latest-node-lts-${{ hashFiles('**/package-lock.json') }}" @@ -113,7 +113,7 @@ jobs: run: | echo "dir=$(npm config get cache)" >> $env:GITHUB_OUTPUT - name: 'Cache node_modules' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ matrix.os == 'ubuntu-latest' && '~/.npm' || steps.npm-cache.outputs.dir }} key: "${{ matrix.os }}-node-v${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}" @@ -152,7 +152,7 @@ jobs: with: persist-credentials: false - name: 'Cache node_modules' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: '~/.npm' # this key is different than above, since we are running scripts @@ -189,7 +189,7 @@ jobs: with: persist-credentials: false - name: 'Cache node_modules' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: '~/.npm' # this key is different than above, since we are running scripts From ffd9557ee291047f7beef71a24796ea2da256614 Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Tue, 26 Mar 2024 19:10:49 +0100 Subject: [PATCH 08/34] Release v10.4.0 --- AUTHORS | 7 +++++++ CHANGELOG.md | 27 +++++++++++++++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index 5c1b272542..17d79bd2be 100644 --- a/AUTHORS +++ b/AUTHORS @@ -547,5 +547,12 @@ Aras Abbasi Spencer <16455389+Spencer-Doak@users.noreply.github.com> Feng Yu Pelle Wessman +Orgad Shaneh +Lucas Lopes +Bryan Mishkin <698306+bmish@users.noreply.github.com> +Ville Lahdenvuo +Nathan Phillip Brink +Ståle Tomten +dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> # Generated by scripts/update-authors.js diff --git a/CHANGELOG.md b/CHANGELOG.md index d6938d051b..62a37eb7a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,32 @@ # Changelog +## 10.4.0 / 2024-03-26 + +### :tada: Enhancements + +- [#4829](https://github.com/mochajs/mocha/pull/4829) feat: include `.cause` stacks in the error stack traces ([**@voxpelli**](https://github.com/voxpelli)) +- [#4985](https://github.com/mochajs/mocha/pull/4985) feat: add file path to xunit reporter ([**@bmish**](https://github.com/bmish)) + +### :bug: Fixes + +- [#5074](https://github.com/mochajs/mocha/pull/5074) fix: harden error handling in `lib/cli/run.js` ([**@stalet**](https://github.com/stalet)) + +### :nut_and_bolt: Other + +- [#5077](https://github.com/mochajs/mocha/pull/5077) chore: add mtfoley/pr-compliance-action ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) +- [#5060](https://github.com/mochajs/mocha/pull/5060) chore: migrate ESLint config to flat config ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) +- [#5095](https://github.com/mochajs/mocha/pull/5095) chore: revert [#5069](https://github.com/mochajs/mocha/pull/5069) to restore Netlify builds ([**@voxpelli**](https://github.com/voxpelli)) +- [#5097](https://github.com/mochajs/mocha/pull/5097) docs: add sponsored to sponsorship link rels ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) +- [#5093](https://github.com/mochajs/mocha/pull/5093) chore: add 'status: in triage' label to issue templates and docs ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) +- [#5083](https://github.com/mochajs/mocha/pull/5083) docs: fix CHANGELOG.md headings to start with a root-level h1 ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) +- [#5100](https://github.com/mochajs/mocha/pull/5100) chore: fix header generation and production build crashes ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) +- [#5104](https://github.com/mochajs/mocha/pull/5104) chore: bump ESLint ecmaVersion to 2020 ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) +- [#5116](https://github.com/mochajs/mocha/pull/5116) fix: eleventy template builds crash with 'unexpected token at ": string, msg..."' ([**@LcsK**](https://github.com/LcsK)) +- [#4869](https://github.com/mochajs/mocha/pull/4869) docs: fix documentation concerning glob expansion on UNIX ([**@binki**](https://github.com/binki)) +- [#5122](https://github.com/mochajs/mocha/pull/5122) test: fix xunit integration test ([**@voxpelli**](https://github.com/voxpelli)) +- [#5123](https://github.com/mochajs/mocha/pull/5123) chore: activate dependabot for workflows ([**@voxpelli**](https://github.com/voxpelli)) +- [#5125](https://github.com/mochajs/mocha/pull/5125) build(deps): bump the github-actions group with 2 updates ([**@dependabot**](https://github.com/dependabot)) + ## 10.3.0 / 2024-02-08 This is a stable release equivalent to [10.30.0-prerelease](#1030-prerelease--2024-01-18). diff --git a/package-lock.json b/package-lock.json index f69412b755..3dad2b0e46 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mocha", - "version": "10.3.0", + "version": "10.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mocha", - "version": "10.3.0", + "version": "10.4.0", "license": "MIT", "dependencies": { "ansi-colors": "4.1.1", diff --git a/package.json b/package.json index 1408b8715c..ed5d6ea47e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mocha", - "version": "10.3.0", + "version": "10.4.0", "type": "commonjs", "description": "simple, flexible, fun test framework", "keywords": [ From e263c7a722b8c2fcbe83596836653896a9e0258b Mon Sep 17 00:00:00 2001 From: Sleepy Flower Date: Wed, 27 Mar 2024 08:07:24 -0400 Subject: [PATCH 09/34] feat: use and for browser progress indicator instead of (#5015) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fallback for progress when canvas isn't available * Fix bugs preventing progress text from being updated * Use a different class for progress text fallback * Refactor: replace progress canvas with text * refactor: add progress bar * Refactor: Remove unused progress code * Match progress design hide progress bar and use SVG to recreate the ring bar * Refactor: use css variables for ring size and color values removed more canvas related code removed an em * Mirror styles changes to progress ring renamed ring-whole to ring-flatlight and have ring highlight and flatlight be the inverse of each other fix spelling error with decimalPlaces use getComputedStyle for get the radius of the ring defined in CSS use :is() CSS to simplify CSS code Change stroke thickness math to better match previous look * Trying to match progress canvas look on progress ring --------- Co-authored-by: Josh Goldberg ✨ --- lib/browser/progress.js | 138 ---------------------------------------- lib/reporters/html.js | 49 +++++++------- mocha.css | 71 ++++++++++++++++----- 3 files changed, 81 insertions(+), 177 deletions(-) delete mode 100644 lib/browser/progress.js diff --git a/lib/browser/progress.js b/lib/browser/progress.js deleted file mode 100644 index c82bc0824e..0000000000 --- a/lib/browser/progress.js +++ /dev/null @@ -1,138 +0,0 @@ -'use strict'; - -/** - @module browser/Progress -*/ - -/** - * Expose `Progress`. - */ - -module.exports = Progress; - -/** - * Initialize a new `Progress` indicator. - */ -function Progress() { - this.percent = 0; - this.size(0); - this.fontSize(11); - this.font('helvetica, arial, sans-serif'); -} - -/** - * Set progress size to `size`. - * - * @public - * @param {number} size - * @return {Progress} Progress instance. - */ -Progress.prototype.size = function (size) { - this._size = size; - return this; -}; - -/** - * Set text to `text`. - * - * @public - * @param {string} text - * @return {Progress} Progress instance. - */ -Progress.prototype.text = function (text) { - this._text = text; - return this; -}; - -/** - * Set font size to `size`. - * - * @public - * @param {number} size - * @return {Progress} Progress instance. - */ -Progress.prototype.fontSize = function (size) { - this._fontSize = size; - return this; -}; - -/** - * Set font to `family`. - * - * @param {string} family - * @return {Progress} Progress instance. - */ -Progress.prototype.font = function (family) { - this._font = family; - return this; -}; - -/** - * Update percentage to `n`. - * - * @param {number} n - * @return {Progress} Progress instance. - */ -Progress.prototype.update = function (n) { - this.percent = n; - return this; -}; - -/** - * Draw on `ctx`. - * - * @param {CanvasRenderingContext2d} ctx - * @return {Progress} Progress instance. - */ -Progress.prototype.draw = function (ctx) { - try { - var darkMatcher = window.matchMedia('(prefers-color-scheme: dark)'); - var isDarkMode = !!darkMatcher.matches; - var lightColors = { - outerCircle: '#9f9f9f', - innerCircle: '#eee', - text: '#000' - }; - var darkColors = { - outerCircle: '#888', - innerCircle: '#444', - text: '#fff' - }; - var colors = isDarkMode ? darkColors : lightColors; - - var percent = Math.min(this.percent, 100); - var size = this._size; - var half = size / 2; - var x = half; - var y = half; - var rad = half - 1; - var fontSize = this._fontSize; - - ctx.font = fontSize + 'px ' + this._font; - - var angle = Math.PI * 2 * (percent / 100); - ctx.clearRect(0, 0, size, size); - - // outer circle - ctx.strokeStyle = colors.outerCircle; - ctx.beginPath(); - ctx.arc(x, y, rad, 0, angle, false); - ctx.stroke(); - - // inner circle - ctx.strokeStyle = colors.innerCircle; - ctx.beginPath(); - ctx.arc(x, y, rad - 1, 0, angle, true); - ctx.stroke(); - - // text - var text = this._text || (percent | 0) + '%'; - var w = ctx.measureText(text).width; - - ctx.fillStyle = colors.text; - ctx.fillText(text, x - w / 2 + 1, y + fontSize / 2 - 1); - } catch (ignore) { - // don't fail if we can't render progress - } - return this; -}; diff --git a/lib/reporters/html.js b/lib/reporters/html.js index 034fb07f01..ae4a4546f8 100644 --- a/lib/reporters/html.js +++ b/lib/reporters/html.js @@ -10,7 +10,6 @@ var Base = require('./base'); var utils = require('../utils'); -var Progress = require('../browser/progress'); var escapeRe = require('escape-string-regexp'); var constants = require('../runner').constants; var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; @@ -38,7 +37,7 @@ exports = module.exports = HTML; var statsTemplate = '
    ' + - '
  • ' + + '
  • 0%
  • ' + '
  • passes: 0
  • ' + '
  • failures: 0
  • ' + '
  • duration: 0s
  • ' + @@ -68,24 +67,16 @@ function HTML(runner, options) { var failures = items[2].getElementsByTagName('em')[0]; var failuresLink = items[2].getElementsByTagName('a')[0]; var duration = items[3].getElementsByTagName('em')[0]; - var canvas = stat.getElementsByTagName('canvas')[0]; var report = fragment('
      '); var stack = [report]; - var progress; - var ctx; + var progressText = items[0].getElementsByTagName('div')[0]; + var progressBar = items[0].getElementsByTagName('progress')[0]; + var progressRing = [ + items[0].getElementsByClassName('ring-flatlight')[0], + items[0].getElementsByClassName('ring-highlight')[0]]; + var progressRingRadius = null; // computed CSS unavailable now, so set later var root = document.getElementById('mocha'); - if (canvas.getContext) { - var ratio = window.devicePixelRatio || 1; - canvas.style.width = canvas.width; - canvas.style.height = canvas.height; - canvas.width *= ratio; - canvas.height *= ratio; - ctx = canvas.getContext('2d'); - ctx.scale(ratio, ratio); - progress = new Progress(); - } - if (!root) { return error('#mocha div missing, add it to your document'); } @@ -115,10 +106,6 @@ function HTML(runner, options) { root.appendChild(stat); root.appendChild(report); - if (progress) { - progress.size(40); - } - runner.on(EVENT_SUITE_BEGIN, function (suite) { if (suite.root) { return; @@ -234,8 +221,26 @@ function HTML(runner, options) { function updateStats() { // TODO: add to stats var percent = ((stats.tests / runner.total) * 100) | 0; - if (progress) { - progress.update(percent).draw(ctx); + progressBar.value = percent; + if (progressText) { + // setting a toFixed that is too low, makes small changes to progress not shown + // setting it too high, makes the progress text longer then it needs to + // to address this, calculate the toFixed based on the magnitude of total + var decimalPlaces = Math.ceil(Math.log10(runner.total / 100)); + text( + progressText, + percent.toFixed(Math.min(Math.max(decimalPlaces, 0), 100)) + '%' + ); + } + if (progressRing) { + var radius = parseFloat(getComputedStyle(progressRing[0]).getPropertyValue('r')); + var wholeArc = Math.PI * 2 * radius; + var highlightArc = percent * (wholeArc / 100); + // The progress ring is in 2 parts, the flatlight color and highlight color. + // Rendering both on top of the other, seems to make a 3rd color on the edges. + // To create 1 whole ring with 2 colors, both parts are inverse of the other. + progressRing[0].style['stroke-dasharray'] = `0,${highlightArc}px,${wholeArc}px`; + progressRing[1].style['stroke-dasharray'] = `${highlightArc}px,${wholeArc}px`; } // update stats diff --git a/mocha.css b/mocha.css index b4d7e5b207..1e0d22249a 100644 --- a/mocha.css +++ b/mocha.css @@ -22,6 +22,9 @@ --mocha-stats-color: #888; --mocha-stats-em-color: #000; --mocha-stats-hover-color: #eee; + --mocha-progress-ring-color: #eee; + --mocha-progress-ring-highlight-color: #9f9f9f; + --mocha-progress-text-color: #000; --mocha-error-color: #c00; --mocha-code-comment: #ddd; @@ -54,6 +57,9 @@ --mocha-stats-color: #aaa; --mocha-stats-em-color: #fff; --mocha-stats-hover-color: #444; + --mocha-progress-ring-color: #444; + --mocha-progress-ring-highlight-color: #888; + --mocha-progress-text-color: #fff; --mocha-error-color: #f44; --mocha-code-comment: #ddd; @@ -325,6 +331,10 @@ body { } #mocha-stats { + --ring-container-size: 40px; + --ring-size: 39px; + --ring-radius: calc(var(--ring-size) / 2); + position: fixed; top: 15px; right: 10px; @@ -334,20 +344,52 @@ body { z-index: 1; } -#mocha-stats .progress { +#mocha-stats .progress-contain { float: right; - padding-top: 0; + padding: 0; +} + +#mocha-stats :is(.progress-element, .progress-text) { + width: var(--ring-container-size); + display: block; + top: 12px; + position: absolute; +} + +#mocha-stats .progress-element { + visibility: hidden; + height: calc(var(--ring-container-size) / 2); +} + +#mocha-stats .progress-text { + text-align: center; + text-overflow: clip; + overflow: hidden; + color: var(--mocha-stats-em-color); + font-size: 11px; +} - /** - * Set safe initial values, so mochas .progress does not inherit these - * properties from Bootstrap .progress (which causes .progress height to - * equal line height set in Bootstrap). - */ - height: auto; - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; - background-color: initial; +#mocha-stats .progress-ring { + width: var(--ring-container-size); + height: var(--ring-container-size); +} + +#mocha-stats :is(.ring-flatlight, .ring-highlight) { + --stroke-thickness: 1.65px; + --center: calc(var(--ring-container-size) / 2); + cx: var(--center); + cy: var(--center); + r: calc(var(--ring-radius) - calc(var(--stroke-thickness) / 2)); + fill: hsla(0, 0%, 0%, 0); + stroke-width: var(--stroke-thickness); +} + +#mocha-stats .ring-flatlight { + stroke: var(--mocha-progress-ring-color); +} + +#mocha-stats .ring-highlight { + stroke: var(--mocha-progress-ring-highlight-color); } #mocha-stats em { @@ -370,11 +412,6 @@ body { padding-top: 11px; } -#mocha-stats canvas { - width: 40px; - height: 40px; -} - #mocha code .comment { color: var(--mocha-code-comment); } #mocha code .init { color: var(--mocha-code-init); } #mocha code .string { color: var(--mocha-code-string); } From 99601da68d59572b6aa931e9416002bcb5b3e19d Mon Sep 17 00:00:00 2001 From: StevenMia <166844090+StevenMia@users.noreply.github.com> Date: Tue, 23 Apr 2024 23:07:43 +0800 Subject: [PATCH 10/34] chore: fix some typos in comments (#5135) Signed-off-by: StevenMia --- docs/changelogs/CHANGELOG_V3_older.md | 2 +- docs/index.md | 2 +- lib/nodejs/reporters/parallel-buffered.js | 2 +- lib/nodejs/serializer.js | 2 +- package-scripts.js | 2 +- test/integration/README.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/changelogs/CHANGELOG_V3_older.md b/docs/changelogs/CHANGELOG_V3_older.md index d9ca257f05..a3b6dfd503 100644 --- a/docs/changelogs/CHANGELOG_V3_older.md +++ b/docs/changelogs/CHANGELOG_V3_older.md @@ -789,7 +789,7 @@ Thanks to everyone who contributed, and our fabulous [sponsors and backers](http # 1.10.0 / 2013-05-21 -- add add better globbing support for windows via `glob` module +- add better globbing support for windows via `glob` module - add support to pass through flags such as --debug-brk=1234. Closes [#852](https://github.com/mochajs/mocha/issues/852) - add test.only, test.skip to qunit interface - change to always use word-based diffs for now. Closes [#733](https://github.com/mochajs/mocha/issues/733) diff --git a/docs/index.md b/docs/index.md index a56b64adde..997a90e553 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1458,7 +1458,7 @@ Available root hooks and their behavior: > _Tip: If you need to ensure code runs once and only once in any mode, use [global fixtures](#global-fixtures)._ -As with other hooks, `this` refers to to the current context object: +As with other hooks, `this` refers to the current context object: ```js // test/hooks.mjs diff --git a/lib/nodejs/reporters/parallel-buffered.js b/lib/nodejs/reporters/parallel-buffered.js index 840d718ed8..b697312e62 100644 --- a/lib/nodejs/reporters/parallel-buffered.js +++ b/lib/nodejs/reporters/parallel-buffered.js @@ -54,7 +54,7 @@ const ONCE_EVENT_NAMES = [EVENT_DELAY_BEGIN, EVENT_DELAY_END]; /** * The `ParallelBuffered` reporter is used by each worker process in "parallel" - * mode, by default. Instead of reporting to to `STDOUT`, etc., it retains a + * mode, by default. Instead of reporting to `STDOUT`, etc., it retains a * list of events it receives and hands these off to the callback passed into * {@link Mocha#run}. That callback will then return the data to the main * process. diff --git a/lib/nodejs/serializer.js b/lib/nodejs/serializer.js index b25c493bf0..cfdd3a69fd 100644 --- a/lib/nodejs/serializer.js +++ b/lib/nodejs/serializer.js @@ -117,7 +117,7 @@ class SerializableEvent { /** * Constructs a `SerializableEvent`, throwing if we receive unexpected data. * - * Practically, events emitted from `Runner` have a minumum of zero (0) + * Practically, events emitted from `Runner` have a minimum of zero (0) * arguments-- (for example, {@link Runnable.constants.EVENT_RUN_BEGIN}) and a * maximum of two (2) (for example, * {@link Runnable.constants.EVENT_TEST_FAIL}, where the second argument is an diff --git a/package-scripts.js b/package-scripts.js index 1e4c072973..3ffd751811 100644 --- a/package-scripts.js +++ b/package-scripts.js @@ -110,7 +110,7 @@ module.exports = { }, qunit: { script: test('qunit', '--ui qunit test/interfaces/qunit.spec'), - description: 'Run Node.js QUnit interace tests', + description: 'Run Node.js QUnit interface tests', hiddenFromHelp: true }, exports: { diff --git a/test/integration/README.md b/test/integration/README.md index 5b2e84d750..dd7fa87f77 100644 --- a/test/integration/README.md +++ b/test/integration/README.md @@ -31,7 +31,7 @@ The `helpers.js` module contains many functions to handle the common cases of sp By default, all of these helpers run with the following options: - `--no-color`: it's easier to make assertions about output w/o having to deal w/ ANSI escape codes -- `--no-bail`: overrides a configuration file w/ `bail: true`; providing `--bail` to the arguments list will supress this (useful when testing `--bail`!) +- `--no-bail`: overrides a configuration file w/ `bail: true`; providing `--bail` to the arguments list will suppress this (useful when testing `--bail`!) - `--no-parallel`: overrides a configuration file w/ `parallel: true`; providing `--parallel` to the arguments list will suppress this ## Environment Variables Which Do Stuff From 472a8be14f9b578c8b1ef3e6ae05d06fc2d9891b Mon Sep 17 00:00:00 2001 From: Simon Hanna <33220646+simhnna@users.noreply.github.com> Date: Fri, 24 May 2024 15:01:48 +0200 Subject: [PATCH 11/34] chore: allow using any 3.x chokidar dependencies (#5143) --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3dad2b0e46..1c22fd5d1d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", - "chokidar": "3.5.3", + "chokidar": "^3.5.3", "debug": "4.3.4", "diff": "5.0.0", "escape-string-regexp": "4.0.0", diff --git a/package.json b/package.json index ed5d6ea47e..417fe13452 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "dependencies": { "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", - "chokidar": "3.5.3", + "chokidar": "^3.5.3", "debug": "4.3.4", "diff": "5.0.0", "escape-string-regexp": "4.0.0", From 5b7af5eec2098f094fe1601b0c5b85499fa67828 Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Tue, 4 Jun 2024 10:34:32 -0400 Subject: [PATCH 12/34] feat: add MOCHA_OPTIONS env variable (#4835) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Josh Goldberg ✨ --- docs/index.md | 11 +++++++ lib/cli/options.js | 17 +++++++--- test/node-unit/cli/options.spec.js | 52 ++++++++++++++++++++++++++++-- 3 files changed, 73 insertions(+), 7 deletions(-) diff --git a/docs/index.md b/docs/index.md index 997a90e553..22ec2a0d33 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2214,11 +2214,22 @@ If no custom path was given, and if there are multiple configuration files in th 1. `.mocharc.jsonc` 1. `.mocharc.json` +### Environment Variables + +The `MOCHA_OPTIONS` environment variable may be used to specify command line arguments. These arguments take priority over those found in configuration files. + +For example, setting the `bail` and `retries` options: + +```bash +$ MOCHA_OPTIONS="--bail --retries 3" mocha +``` + ### Merging Mocha will also _merge_ any options found in `package.json` into its run-time configuration. In case of conflict, the priority is: 1. Arguments specified on command-line +1. Arguments specified in `MOCHA_OPTIONS` environment variable. 1. Configuration file (`.mocharc.js`, `.mocharc.yml`, etc.) 1. `mocha` property of `package.json` diff --git a/lib/cli/options.js b/lib/cli/options.js index 8fa9470e6f..d238737d37 100644 --- a/lib/cli/options.js +++ b/lib/cli/options.js @@ -208,9 +208,10 @@ module.exports.loadPkgRc = loadPkgRc; * Priority list: * * 1. Command-line args - * 2. RC file (`.mocharc.c?js`, `.mocharc.ya?ml`, `mocharc.json`) - * 3. `mocha` prop of `package.json` - * 4. default configuration (`lib/mocharc.json`) + * 2. `MOCHA_OPTIONS` environment variable. + * 3. RC file (`.mocharc.c?js`, `.mocharc.ya?ml`, `mocharc.json`) + * 4. `mocha` prop of `package.json` + * 5. default configuration (`lib/mocharc.json`) * * If a {@link module:lib/cli/one-and-dones.ONE_AND_DONE_ARGS "one-and-done" option} is present in the `argv` array, no external config files will be read. * @summary Parses options read from `.mocharc.*` and `package.json`. @@ -231,6 +232,7 @@ const loadOptions = (argv = []) => { return args; } + const envConfig = parse(process.env.MOCHA_OPTIONS || ''); const rcConfig = loadRc(args); const pkgConfig = loadPkgRc(args); @@ -243,7 +245,14 @@ const loadOptions = (argv = []) => { args._ = args._.concat(pkgConfig._ || []); } - args = parse(args._, mocharc, args, rcConfig || {}, pkgConfig || {}); + args = parse( + args._, + mocharc, + args, + envConfig, + rcConfig || {}, + pkgConfig || {} + ); // recombine positional arguments and "spec" if (args.spec) { diff --git a/test/node-unit/cli/options.spec.js b/test/node-unit/cli/options.spec.js index 0508514cdd..60357d12ae 100644 --- a/test/node-unit/cli/options.spec.js +++ b/test/node-unit/cli/options.spec.js @@ -42,9 +42,10 @@ describe('options', function () { /** * Order of priority: * 1. Command-line args - * 2. RC file (`.mocharc.js`, `.mocharc.ya?ml`, `mocharc.json`) - * 3. `mocha` prop of `package.json` - * 4. default rc + * 2. `MOCHA_OPTIONS` environment variable + * 3. RC file (`.mocharc.js`, `.mocharc.ya?ml`, `mocharc.json`) + * 4. `mocha` prop of `package.json` + * 5. default rc */ describe('loadOptions()', function () { describe('when no parameter provided', function () { @@ -408,6 +409,30 @@ describe('options', function () { }); }); + describe('env options', function () { + it('should parse flags from MOCHA_OPTIONS', function () { + readFileSync = sinon.stub().onFirstCall().returns('{}'); + findConfig = sinon.stub().returns('/some/.mocharc.json'); + loadConfig = sinon.stub().returns({}); + findupSync = sinon.stub().returns('/some/package.json'); + sinon + .stub(process, 'env') + .value({MOCHA_OPTIONS: '--retries 42 --color'}); + + loadOptions = proxyLoadOptions({ + readFileSync, + findConfig, + loadConfig, + findupSync + }); + + expect(loadOptions(), 'to satisfy', { + retries: 42, + color: true + }); + }); + }); + describe('config priority', function () { it('should prioritize package.json over defaults', function () { readFileSync = sinon.stub(); @@ -474,6 +499,27 @@ describe('options', function () { '500' ); }); + + it('should prioritize env over rc file', function () { + readFileSync = sinon.stub(); + readFileSync.onFirstCall().returns('{}'); + readFileSync.onSecondCall().returns(''); + findConfig = sinon.stub().returns('/some/.mocharc.json'); + loadConfig = sinon.stub().returns({retries: 300}); + findupSync = sinon.stub().returns('/some/package.json'); + sinon + .stub(process, 'env') + .value({MOCHA_OPTIONS: '--retries 800 --color'}); + + loadOptions = proxyLoadOptions({ + readFileSync, + findConfig, + loadConfig, + findupSync + }); + + expect(loadOptions(), 'to have property', 'retries', 800); + }); }); describe('when called with a one-and-done arg', function () { From 6dda9a476b54a9c00bacdb45aac74586ebeb42c2 Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Fri, 7 Jun 2024 12:59:40 +0200 Subject: [PATCH 13/34] chore: remove `husky` for now (#5127) Fixes #5124 --- package-lock.json | 169 ---------------------------------------------- package.json | 6 -- 2 files changed, 175 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1c22fd5d1d..7d5c3379ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,7 +54,6 @@ "fail-on-errors-webpack-plugin": "^3.0.0", "fs-extra": "^10.0.0", "globals": "^13.24.0", - "husky": "^4.2.5", "hyperlink": "^5.0.4", "jsdoc": "^3.6.7", "jsdoc-ts-utils": "^2.0.1", @@ -4999,12 +4998,6 @@ "integrity": "sha512-3Lc0sTIuX1jmY2K2RrXRJOND6KsRTX2D4v3+eu1PDptsuJZVK4LZc852eZa9I+avj0NrUKlTNgqvccNOH6mbGg==", "dev": true }, - "node_modules/compare-versions": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.6.0.tgz", - "integrity": "sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA==", - "dev": true - }, "node_modules/compress-commons": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/compress-commons/-/compress-commons-4.1.1.tgz", @@ -8094,21 +8087,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/find-versions": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/find-versions/-/find-versions-4.0.0.tgz", - "integrity": "sha512-wgpWy002tA+wgmO27buH/9KzyEOQnKsG/R0yrcjPT9BOFm0zRBVQbZ95nRGXWMywS8YR5knRbpohio0bcJABxQ==", - "dev": true, - "dependencies": { - "semver-regex": "^3.1.2" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/flat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", @@ -9292,36 +9270,6 @@ "node": ">=8.12.0" } }, - "node_modules/husky": { - "version": "4.3.8", - "resolved": "https://registry.npmjs.org/husky/-/husky-4.3.8.tgz", - "integrity": "sha512-LCqqsB0PzJQ/AlCgfrfzRe3e3+NvmefAdKQhRYpxS4u6clblBoDdzzvHi8fmxKRzvMxPY/1WZWzomPZww0Anow==", - "dev": true, - "hasInstallScript": true, - "dependencies": { - "chalk": "^4.0.0", - "ci-info": "^2.0.0", - "compare-versions": "^3.6.0", - "cosmiconfig": "^7.0.0", - "find-versions": "^4.0.0", - "opencollective-postinstall": "^2.0.2", - "pkg-dir": "^5.0.0", - "please-upgrade-node": "^3.2.0", - "slash": "^3.0.0", - "which-pm-runs": "^1.0.0" - }, - "bin": { - "husky-run": "bin/run.js", - "husky-upgrade": "lib/upgrader/bin.js" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/husky" - } - }, "node_modules/hyperlink": { "version": "5.0.4", "resolved": "https://registry.npmjs.org/hyperlink/-/hyperlink-5.0.4.tgz", @@ -14619,15 +14567,6 @@ "node": ">=8" } }, - "node_modules/opencollective-postinstall": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz", - "integrity": "sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==", - "dev": true, - "bin": { - "opencollective-postinstall": "index.js" - } - }, "node_modules/openurl": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/openurl/-/openurl-1.1.1.tgz", @@ -15350,18 +15289,6 @@ "node": ">=0.10.0" } }, - "node_modules/pkg-dir": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-5.0.0.tgz", - "integrity": "sha512-NPE8TDbzl/3YQYY7CSS228s3g2ollTFnc+Qi3tqmqJp9Vg2ovUpixcJEo2HJScN2Ez+kEaal6y70c0ehqJBJeA==", - "dev": true, - "dependencies": { - "find-up": "^5.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/please-upgrade-node": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", @@ -18322,18 +18249,6 @@ "semver": "bin/semver.js" } }, - "node_modules/semver-regex": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/semver-regex/-/semver-regex-3.1.4.tgz", - "integrity": "sha512-6IiqeZNgq01qGf0TId0t3NvKzSvUsjcpdEO3AQNeIjR6A2+ckTnQlDpl4qu1bjRv0RzN3FP9hzFmws3lKqRWkA==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/semver-truncate": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/semver-truncate/-/semver-truncate-1.1.2.tgz", @@ -18838,15 +18753,6 @@ "node": ">=8" } }, - "node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/slice-ansi": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-3.0.0.tgz", @@ -21777,15 +21683,6 @@ "integrity": "sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==", "dev": true }, - "node_modules/which-pm-runs": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/which-pm-runs/-/which-pm-runs-1.1.0.tgz", - "integrity": "sha512-n1brCuqClxfFfq/Rb0ICg9giSZqCS+pLtccdag6C2HyufBrh3fBOiy9nb6ggRMvWOVH5GrdJskj5iGTZNxd7SA==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/which-typed-array": { "version": "1.1.9", "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz", @@ -26341,12 +26238,6 @@ "integrity": "sha512-3Lc0sTIuX1jmY2K2RrXRJOND6KsRTX2D4v3+eu1PDptsuJZVK4LZc852eZa9I+avj0NrUKlTNgqvccNOH6mbGg==", "dev": true }, - "compare-versions": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.6.0.tgz", - "integrity": "sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA==", - "dev": true - }, "compress-commons": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/compress-commons/-/compress-commons-4.1.1.tgz", @@ -28814,15 +28705,6 @@ "path-exists": "^4.0.0" } }, - "find-versions": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/find-versions/-/find-versions-4.0.0.tgz", - "integrity": "sha512-wgpWy002tA+wgmO27buH/9KzyEOQnKsG/R0yrcjPT9BOFm0zRBVQbZ95nRGXWMywS8YR5knRbpohio0bcJABxQ==", - "dev": true, - "requires": { - "semver-regex": "^3.1.2" - } - }, "flat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", @@ -29736,24 +29618,6 @@ "integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==", "dev": true }, - "husky": { - "version": "4.3.8", - "resolved": "https://registry.npmjs.org/husky/-/husky-4.3.8.tgz", - "integrity": "sha512-LCqqsB0PzJQ/AlCgfrfzRe3e3+NvmefAdKQhRYpxS4u6clblBoDdzzvHi8fmxKRzvMxPY/1WZWzomPZww0Anow==", - "dev": true, - "requires": { - "chalk": "^4.0.0", - "ci-info": "^2.0.0", - "compare-versions": "^3.6.0", - "cosmiconfig": "^7.0.0", - "find-versions": "^4.0.0", - "opencollective-postinstall": "^2.0.2", - "pkg-dir": "^5.0.0", - "please-upgrade-node": "^3.2.0", - "slash": "^3.0.0", - "which-pm-runs": "^1.0.0" - } - }, "hyperlink": { "version": "5.0.4", "resolved": "https://registry.npmjs.org/hyperlink/-/hyperlink-5.0.4.tgz", @@ -33789,12 +33653,6 @@ } } }, - "opencollective-postinstall": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz", - "integrity": "sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==", - "dev": true - }, "openurl": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/openurl/-/openurl-1.1.1.tgz", @@ -34351,15 +34209,6 @@ "pinkie": "^2.0.0" } }, - "pkg-dir": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-5.0.0.tgz", - "integrity": "sha512-NPE8TDbzl/3YQYY7CSS228s3g2ollTFnc+Qi3tqmqJp9Vg2ovUpixcJEo2HJScN2Ez+kEaal6y70c0ehqJBJeA==", - "dev": true, - "requires": { - "find-up": "^5.0.0" - } - }, "please-upgrade-node": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", @@ -36621,12 +36470,6 @@ } } }, - "semver-regex": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/semver-regex/-/semver-regex-3.1.4.tgz", - "integrity": "sha512-6IiqeZNgq01qGf0TId0t3NvKzSvUsjcpdEO3AQNeIjR6A2+ckTnQlDpl4qu1bjRv0RzN3FP9hzFmws3lKqRWkA==", - "dev": true - }, "semver-truncate": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/semver-truncate/-/semver-truncate-1.1.2.tgz", @@ -37028,12 +36871,6 @@ } } }, - "slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true - }, "slice-ansi": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-3.0.0.tgz", @@ -39306,12 +39143,6 @@ "integrity": "sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q==", "dev": true }, - "which-pm-runs": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/which-pm-runs/-/which-pm-runs-1.1.0.tgz", - "integrity": "sha512-n1brCuqClxfFfq/Rb0ICg9giSZqCS+pLtccdag6C2HyufBrh3fBOiy9nb6ggRMvWOVH5GrdJskj5iGTZNxd7SA==", - "dev": true - }, "which-typed-array": { "version": "1.1.9", "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz", diff --git a/package.json b/package.json index 417fe13452..f4fcf530e5 100644 --- a/package.json +++ b/package.json @@ -92,7 +92,6 @@ "fail-on-errors-webpack-plugin": "^3.0.0", "fs-extra": "^10.0.0", "globals": "^13.24.0", - "husky": "^4.2.5", "hyperlink": "^5.0.4", "jsdoc": "^3.6.7", "jsdoc-ts-utils": "^2.0.1", @@ -168,10 +167,5 @@ }, "overrides": { "webdriverio": "^7.33.0" - }, - "husky": { - "hooks": { - "pre-commit": "lint-staged" - } } } From 2f3fedcc41cbb9d3e503d84098fcc07d7c3c49f1 Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Fri, 7 Jun 2024 13:37:58 +0200 Subject: [PATCH 14/34] chore: allow blank issues (#5157) I personally think we should allow for blank issues even though we might prioritize them lower. I can take it upon myself to triage all the blank issues if that's the sticking point. --- .github/ISSUE_TEMPLATE/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index dbdd514b0c..14346bf54f 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,4 +1,4 @@ -blank_issues_enabled: false +blank_issues_enabled: true contact_links: - name: Documentation Website about: Please read our documentation website before filing new issues. From e0301154101989a26877fbb8a1e9c869c9f3e4a6 Mon Sep 17 00:00:00 2001 From: Marjorie Saito Date: Wed, 19 Jun 2024 10:54:06 -0300 Subject: [PATCH 15/34] chore: switch two-column list styles to be opt-in (#5110) * style: closes mochajs#3702 - Adds the two-column class with the expected style for two-column unordered lists, making sure to keep the two-column style at Features and Table of Contents - Removes column style from ul element scope * refactor: add two-column class to the toc Use the class two-column instead of applying the style by using its id. * refactor: move styles that are overwritten within other classes Move margin-top and padding inside two-column as they are overwritten within single-column. --- docs/css/style.css | 6 ++++-- docs/index.md | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/css/style.css b/docs/css/style.css index 79dbc261e8..c36f73c85d 100644 --- a/docs/css/style.css +++ b/docs/css/style.css @@ -180,6 +180,9 @@ a.direct-link { ul { box-sizing: content-box; +} + +ul.two-column { column-count: 2; column-gap: 30px; margin-top: 20px; @@ -188,9 +191,8 @@ ul { ul.single-column, ul.single-column > li > ul { - column-count: 1; margin-top: 0; - padding-right: 0; + padding: 0 0 0 15px; } ul li { diff --git a/docs/index.md b/docs/index.md index 22ec2a0d33..4c71ef5fec 100644 --- a/docs/index.md +++ b/docs/index.md @@ -44,10 +44,12 @@ Mocha is a feature-rich JavaScript test framework running on [Node.js][] and in - [before, after, before each, after each hooks](#hooks) - [arbitrary transpiler support (coffee-script etc)](#-compilers) - [TextMate bundle](#textmate) + {:.two-column} ## Table of Contents {{ toc }} +{:.two-column} ## Installation From 67a81245f969267dbb1878c73d593d8316d5706f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Sat, 22 Jun 2024 19:15:23 -0400 Subject: [PATCH 16/34] fix: include stack in browser uncaught error reporting (#5107) * Include stack in browser uncaught error reporting * Attempt at testing (failing due to uncaught exception) * Revert "Attempt at testing (failing due to uncaught exception)" This reverts commit 30c7ffb8005937707ee894623d28b054eb621fd8. * implemented test in throw.spec.js & got it passing * Apply suggestions from code review * Update test/unit/throw.spec.js Co-authored-by: Pelle Wessman * test: fix up throw.spec.js --------- Co-authored-by: Peter Rust Co-authored-by: Pelle Wessman --- browser-entry.js | 4 ++-- test/unit/throw.spec.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/browser-entry.js b/browser-entry.js index 67517db357..4e6f9e939a 100644 --- a/browser-entry.js +++ b/browser-entry.js @@ -71,8 +71,8 @@ process.listenerCount = function (name) { process.on = function (e, fn) { if (e === 'uncaughtException') { - global.onerror = function (err, url, line) { - fn(new Error(err + ' (' + url + ':' + line + ')')); + global.onerror = function (msg, url, line, col, err) { + fn(err || new Error(msg + ' (' + url + ':' + line + ':' + col + ')')); return !mocha.options.allowUncaught; }; uncaughtExceptionHandlers.push(fn); diff --git a/test/unit/throw.spec.js b/test/unit/throw.spec.js index ccb7ef6c11..cafadaa4bc 100644 --- a/test/unit/throw.spec.js +++ b/test/unit/throw.spec.js @@ -2,6 +2,7 @@ /* eslint no-throw-literal: off */ +var sinon = require('sinon'); var Mocha = require('../../lib/mocha'); var Suite = Mocha.Suite; var Test = Mocha.Test; @@ -29,6 +30,7 @@ describe('a test that throws', function () { uncaughtHandlers.forEach(function (listener) { process.on('uncaughtException', listener); }); + sinon.restore(); }); describe('non-extensible', function () { @@ -172,4 +174,35 @@ describe('a test that throws', function () { runner.run(); }); }); + + describe('stack', function() { + it('should include the stack when throwing async', function(done) { + var test = new Test('im async and throw null async', function(done2) { + process.nextTick(function throwError() { + throw new Error('test error'); + }); + }); + suite.addTest(test); + runner = new Runner(suite); + sinon.stub(runner, 'fail'); + + runner.on(EVENT_RUN_END, function() { + try { + expect(runner.fail, 'to have all calls satisfying', [ + expect.it('to be a', Runnable), + expect.it('to be an', Error).and('to satisfy', { + message: /test error/i, + stack: /throwError/i, + uncaught: true + }) + ]).and('was called once'); + } catch (err) { + return done(err); + } + + done(); + }); + runner.run(); + }); + }); }); From b6aa7e85b821a7859bb6e372d8c3efe67936d7c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Sat, 22 Jun 2024 19:16:49 -0400 Subject: [PATCH 17/34] chore: rename 'master' to 'main' in docs and tooling (#5130) * chore: rename 'master' to 'main' in docs and tooling * Use new foundation CoC link --- .github/CODE_OF_CONDUCT.md | 2 +- .github/CONTRIBUTING.md | 10 +++++----- .github/ISSUE_TEMPLATE/01-bug.yml | 2 +- .github/ISSUE_TEMPLATE/02-documentation.yml | 2 +- .github/ISSUE_TEMPLATE/03-feature-request.yml | 2 +- .../ISSUE_TEMPLATE/04-repository-tooling.yml | 4 ++-- .github/PULL_REQUEST_TEMPLATE.md | 2 +- .github/workflows/compliance.yml | 2 +- MAINTAINERS.md | 20 +++++++++---------- PROJECT_CHARTER.md | 8 ++++---- README.md | 14 ++++++------- docs/API.md | 4 ++-- docs/README.md | 4 ++-- docs/api-tutorials/custom-reporter.md | 2 +- docs/changelogs/README.md | 2 +- docs/index.md | 12 +++++------ 16 files changed, 46 insertions(+), 46 deletions(-) diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index 93aef1d0cf..d4d5a7ab06 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -100,4 +100,4 @@ This is a foundation-wide team established to manage escalation when a reporter In order to escalate to the CoCP send an email to `"coc-escalation@lists.openjsf.org`. For more information, refer to the full -[Code of Conduct governance document](https://github.com/openjs-foundation/cross-project-council/blob/master/FOUNDATION_CODE_OF_CONDUCT_REQUIREMENTS.md). +[Code of Conduct governance document](https://github.com/openjs-foundation/cross-project-council/tree/main/proposals/approved/CODE_OF_CONDUCT). diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8a9fa714b9..6a60026936 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -99,11 +99,11 @@ Then: - Add detail in subsequent lines. - A pre-commit hook will run which automatically formats your staged changes (and fixes any problems it can) with ESLint and Prettier. If ESLint fails to fix an issue, your commit will fail and you will need to manually correct the problem. -1. (Optional) Ensure you are up-to-date with Mocha's `master` branch: +1. (Optional) Ensure you are up-to-date with Mocha's `main` branch: - You can add an "upstream" remote repo using `git remote add upstream https://github.com/mochajs/mocha.git && git fetch upstream`. - - Navigate to your `master` branch using `git checkout master`. - - Pull changes from `upstream` using `git pull upstream master`. - - If any changes were pulled in, update your branch from `master` by switching back to your branch (`git checkout `) then merging using `git merge master`. + - Navigate to your `main` branch using `git checkout main`. + - Pull changes from `upstream` using `git pull upstream main`. + - If any changes were pulled in, update your branch from `main` by switching back to your branch (`git checkout `) then merging using `git merge main`. 1. Push your changes to your fork; `git push origin`. 1. In your browser, navigate to [mochajs/mocha](https://github.com/mochajs/mocha). You should see a notification about your recent changes in your fork's branch, with a (green?) button to create a pull request. @@ -126,7 +126,7 @@ Now that the pull request exists, some tasks will be run on it: 1. Be patient while your PR is reviewed. This can take a while. We may request changes, but don't be afraid to question them. -1. Your PR might become conflicted with the code in `master`. +1. Your PR might become conflicted with the code in `main`. If this is the case, you will need to [update your PR](#up-to-date) and resolve your conflicts. 1. You don't need to make a new PR to any needed changes. Instead, commit on top of your changes, and push these to your fork's branch. diff --git a/.github/ISSUE_TEMPLATE/01-bug.yml b/.github/ISSUE_TEMPLATE/01-bug.yml index fc43efff3f..b46ae9d9b3 100644 --- a/.github/ISSUE_TEMPLATE/01-bug.yml +++ b/.github/ISSUE_TEMPLATE/01-bug.yml @@ -3,7 +3,7 @@ body: description: If any of these required steps are not taken, we may not be able to review your issue. Help us to help you! label: Bug Report Checklist options: - - label: I have read and agree to Mocha's [Code of Conduct](https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/mochajs/mocha/blob/master/.github/CONTRIBUTING.md) + - label: I have read and agree to Mocha's [Code of Conduct](https://github.com/mochajs/mocha/blob/main/.github/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/mochajs/mocha/blob/main/.github/CONTRIBUTING.md) required: true - label: I have searched for [related issues](https://github.com/mochajs/mocha/issues?q=is%3Aissue) and [issues with the `faq` label](https://github.com/mochajs/mocha/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Afaq%20), but none matched my issue. required: true diff --git a/.github/ISSUE_TEMPLATE/02-documentation.yml b/.github/ISSUE_TEMPLATE/02-documentation.yml index 09517048ac..0a98e59f35 100644 --- a/.github/ISSUE_TEMPLATE/02-documentation.yml +++ b/.github/ISSUE_TEMPLATE/02-documentation.yml @@ -3,7 +3,7 @@ body: description: If any of these required steps are not taken, we may not be able to review your issue. Help us to help you! label: Documentation Request Checklist options: - - label: I have read and agree to Mocha's [Code of Conduct](https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/mochajs/mocha/blob/master/.github/CONTRIBUTING.md) + - label: I have read and agree to Mocha's [Code of Conduct](https://github.com/mochajs/mocha/blob/main/.github/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/mochajs/mocha/blob/main/.github/CONTRIBUTING.md) required: true - label: I have searched for [related issues](https://github.com/mochajs/mocha/issues?q=is%3Aissue) and [issues with the `faq` label](https://github.com/mochajs/mocha/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Afaq%20), but none matched my issue. required: true diff --git a/.github/ISSUE_TEMPLATE/03-feature-request.yml b/.github/ISSUE_TEMPLATE/03-feature-request.yml index 00778f454a..c37843969e 100644 --- a/.github/ISSUE_TEMPLATE/03-feature-request.yml +++ b/.github/ISSUE_TEMPLATE/03-feature-request.yml @@ -3,7 +3,7 @@ body: description: If any of these required steps are not taken, we may not be able to review your issue. Help us to help you! label: Feature Request Checklist options: - - label: I have read and agree to Mocha's [Code of Conduct](https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/mochajs/mocha/blob/master/.github/CONTRIBUTING.md) + - label: I have read and agree to Mocha's [Code of Conduct](https://github.com/mochajs/mocha/blob/main/.github/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/mochajs/mocha/blob/main/.github/CONTRIBUTING.md) required: true - label: I have searched for [related issues](https://github.com/mochajs/mocha/issues?q=is%3Aissue) and [issues with the `faq` label](https://github.com/mochajs/mocha/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Afaq%20), but none matched my issue. required: true diff --git a/.github/ISSUE_TEMPLATE/04-repository-tooling.yml b/.github/ISSUE_TEMPLATE/04-repository-tooling.yml index 3d3908fa31..7e6c6a57f1 100644 --- a/.github/ISSUE_TEMPLATE/04-repository-tooling.yml +++ b/.github/ISSUE_TEMPLATE/04-repository-tooling.yml @@ -5,9 +5,9 @@ body: options: - label: I have tried restarting my IDE and the issue persists. required: true - - label: I have pulled the latest `master` branch of the repository. + - label: I have pulled the latest `main` branch of the repository. required: true - - label: I have read and agree to Mocha's [Code of Conduct](https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/mochajs/mocha/blob/master/.github/CONTRIBUTING.md) + - label: I have read and agree to Mocha's [Code of Conduct](https://github.com/mochajs/mocha/blob/main/.github/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/mochajs/mocha/blob/main/.github/CONTRIBUTING.md) required: true - label: I have searched for [related issues](https://github.com/mochajs/mocha/issues?q=is%3Aissue) and [issues with the `faq` label](https://github.com/mochajs/mocha/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Afaq%20), but none matched my issue. required: true diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 20df860769..9f8ff8ca6a 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -6,7 +6,7 @@ Otherwise we may not be able to review your PR. --> - [ ] Addresses an existing open issue: fixes #000 - [ ] That issue was marked as [`status: accepting prs`](https://github.com/mochajs/mocha/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) -- [ ] Steps in [CONTRIBUTING.md](https://github.com/mochajs/mocha/blob/master/.github/CONTRIBUTING.md) were taken +- [ ] Steps in [CONTRIBUTING.md](https://github.com/mochajs/mocha/blob/main/.github/CONTRIBUTING.md) were taken ## Overview diff --git a/.github/workflows/compliance.yml b/.github/workflows/compliance.yml index 70d9714e5f..99afe754fa 100644 --- a/.github/workflows/compliance.yml +++ b/.github/workflows/compliance.yml @@ -12,7 +12,7 @@ name: Compliance on: pull_request: branches: - - master + - main types: - edited - opened diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 16b4463dd8..308ba603f1 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -25,7 +25,7 @@ A "user" for the purpose of this document is any _individual developer_ who cons A user interacts with contributors. A user interacts with the software, web site, documentation, etc., which these contributors provide. -As a user, you're expected to follow the [code of conduct](https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md) when interacting in Mocha's "official" social spaces. +As a user, you're expected to follow the [code of conduct](https://github.com/mochajs/mocha/blob/main/.github/CODE_OF_CONDUCT.md) when interacting in Mocha's "official" social spaces. This includes: - Any channel under the `mochajs` Discord @@ -54,7 +54,7 @@ Contributions include (but are not limited to): 1. Researching the user base, getting feedback, etc. Don't spam. A contributor is _usually_ a user as well, but this isn't a hard-and-fast rule. -A contributor is also expected to adhere to the [code of conduct](https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md) as a user would. +A contributor is also expected to adhere to the [code of conduct](https://github.com/mochajs/mocha/blob/main/.github/CODE_OF_CONDUCT.md) as a user would. As you can see, it's wide open! Think of it another way: if you are _adding value to Mocha_, then you are a contributor. @@ -123,7 +123,7 @@ You may choose to do zero or more of these _at their discretion_: - Add new maintainers to the team - Tag releases and publish Mocha to npm -> While maintainers have the ability to commit directly to the `master` branch, _this is to be avoided_ if any other maintainer could reasonably take issue with the change, or the change affects Mocha's API or output. +> While maintainers have the ability to commit directly to the `main` branch, _this is to be avoided_ if any other maintainer could reasonably take issue with the change, or the change affects Mocha's API or output. > For example, a spelling correction in `CHANGELOG.md` may not require a pull request. > A change to a reporter's output most certainly would! Maintainers are trusted to use their best judgement; if unsure, err on the side of caution. @@ -347,8 +347,8 @@ Here are some suggestions: ## Branches -`master` is the only maintained branch in `mochajs/mocha` or any of the other repos. -**`master` is the only branch to which force-pushing is disallowed.** +`main` is the only maintained branch in `mochajs/mocha` or any of the other repos. +**`main` is the only branch to which force-pushing is disallowed.** Maintainers may push new branches to a repo, as long as they remove them when finished (merging a PR will prompt to do so). @@ -371,7 +371,7 @@ Likewise, if the PR is `semver-minor`, create or use a new milestone correlating If it's unclear what the next milestone will be, use or create a milestone named `next`. This milestone will be renamed to the new version at release time. -By using milestones, we can cherry-pick non-breaking changes into minor or patch releases, and keep `master` as the latest version. +By using milestones, we can cherry-pick non-breaking changes into minor or patch releases, and keep `main` as the latest version. **This is subject to change, hopefully.** @@ -380,7 +380,7 @@ By using milestones, we can cherry-pick non-breaking changes into minor or patch _It's easier to release often._ 1. Decide whether this is a `patch`, `minor`, or `major` release. -1. Checkout `master` in your working copy & pull. +1. Checkout `main` in your working copy & pull. 1. Modify `CHANGELOG.md`; follow the existing conventions in that file. Use the "pull request" number, unless there isn't one. _You do not need to add Markdown links; this is done automatically._ @@ -391,15 +391,15 @@ _It's easier to release often._ (Hint--use `-m`: e.g., `npm version patch -m 'Release v%s'`) 1. This command will update the list of authors (from the Git history) in `AUTHORS`, and add GitHub links to `CHANGELOG.md`. 1. These changes are then added to the Git "stage" and will be added to the commit. -1. Push `master` to `origin` with your new tag; e.g. `git push origin master --tags` +1. Push `main` to `origin` with your new tag; e.g. `git push origin main --tags` 1. Copy & paste the `CHANGELOG.md` lines to a new GitHub "release". Save release as draft. 1. Meanwhile, you can check [the build](https://travis-ci.org/mochajs/mocha) on Travis-CI and [GitHub Actions](https://github.com/mochajs/mocha/actions?query=workflow%3A%22Windows+CI%22). 1. Once the build is green, you'll want to trigger an update of `mochajs.org`: - 1. _If you're doing a prerelease_, fast-forward the `next` branch to `master`, and push it. + 1. _If you're doing a prerelease_, fast-forward the `next` branch to `main`, and push it. This updates [https://next.mochajs.org](https://next.mochajs.org). That's all. - 1. _If this is NOT a prerelease_, fast-forward the `mochajs.org` branch to `master` and push it. + 1. _If this is NOT a prerelease_, fast-forward the `mochajs.org` branch to `main` and push it. This updates [https://mochajs.org](https://mochajs.org). 1. _If this is a "final" release_ (the first release of a major _after_ one or more prereleases) then remove the `next` tag from npm via `npm dist-tag rm next`. 1. Finally, you're satisfied with the release notes, open your draft release on GitHub, then click "publish." diff --git a/PROJECT_CHARTER.md b/PROJECT_CHARTER.md index 1f3e92e943..3505acb8e4 100644 --- a/PROJECT_CHARTER.md +++ b/PROJECT_CHARTER.md @@ -32,7 +32,7 @@ The **Mocha** project is part of the [OpenJS Foundation], which operates transpa - Command-line execution and options - Browser-based execution and options - [Project administration](https://github.com/mochajs/admin) - - [Contribution guide](https://github.com/mochajs/mocha/blob/master/.github/CONTRIBUTING.md) + - [Contribution guide](https://github.com/mochajs/mocha/blob/main/.github/CONTRIBUTING.md) - General support for multiple levels of tests, including (but not limited to): - Unit tests - Integration tests @@ -72,7 +72,7 @@ Changes to the following **cannot** unilaterally be applied by project leadershi - Mocha's Project Charter (this document) - Mocha's [Code of Conduct] -- Mocha's licenses: [MIT](https://github.com/mochajs/mocha/blob/master/LICENSE) (for code) and [CC-BY-4.0](https://github.com/mochajs/mocha/blob/master/docs/LICENSE-CC-BY-4.0) (for documentation/website) +- Mocha's licenses: [MIT](https://github.com/mochajs/mocha/blob/main/LICENSE) (for code) and [CC-BY-4.0](https://github.com/mochajs/mocha/blob/main/docs/LICENSE-CC-BY-4.0) (for documentation/website) ### §3.1: Other Formal Project Relationships @@ -103,5 +103,5 @@ Section Intentionally Left Blank Section Intentionally Left Blank [openjs foundation]: https://openjsf.org -[maintainers.md]: https://github.com/mochajs/mocha/blob/master/MAINTAINERS.md -[code of conduct]: https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md +[maintainers.md]: https://github.com/mochajs/mocha/blob/main/MAINTAINERS.md +[code of conduct]: https://github.com/mochajs/mocha/blob/main/.github/CODE_OF_CONDUCT.md diff --git a/README.md b/README.md index 3545f7a721..ca740e1715 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@

      ☕️ Simple, flexible, fun JavaScript test framework for Node.js & The Browser ☕️

      -GitHub Actions Build Status +GitHub Actions Build Status Coverage Status FOSSA Status Chat - Discord @@ -23,10 +23,10 @@ ## Links - **[Documentation](https://mochajs.org)** -- **[Release Notes / History / Changes](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md)** -- [Code of Conduct](https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md) -- [Contributing](https://github.com/mochajs/mocha/blob/master/.github/CONTRIBUTING.md) -- [Development](https://github.com/mochajs/mocha/blob/master/.github/DEVELOPMENT.md) +- **[Release Notes / History / Changes](https://github.com/mochajs/mocha/blob/main/CHANGELOG.md)** +- [Code of Conduct](https://github.com/mochajs/mocha/blob/main/.github/CODE_OF_CONDUCT.md) +- [Contributing](https://github.com/mochajs/mocha/blob/main/.github/CONTRIBUTING.md) +- [Development](https://github.com/mochajs/mocha/blob/main/.github/DEVELOPMENT.md) - [Discord](https://discord.gg/KeDn2uXhER) (ask questions here!) - [Issue Tracker](https://github.com/mochajs/mocha/issues) @@ -59,7 +59,7 @@ You might want to help: - New to contributing to Mocha? Check out this list of [good first issues](https://github.com/mochajs/mocha/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) - Mocha could use a hand with [these issues](https://github.com/mochajs/mocha/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) -- The [maintainer's handbook](https://github.com/mochajs/mocha/blob/master/MAINTAINERS.md) explains how things get done +- The [maintainer's handbook](https://github.com/mochajs/mocha/blob/main/MAINTAINERS.md) explains how things get done Finally, come [chat with the maintainers on Discord](https://discord.gg/KeDn2uXhER) if you want to help with: @@ -69,6 +69,6 @@ Finally, come [chat with the maintainers on Discord](https://discord.gg/KeDn2uXh ## License -Copyright 2011-2022 OpenJS Foundation and contributors. Licensed [MIT](https://github.com/mochajs/mocha/blob/master/LICENSE). +Copyright 2011-2022 OpenJS Foundation and contributors. Licensed [MIT](https://github.com/mochajs/mocha/blob/main/LICENSE). [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmochajs%2Fmocha.svg?type=large)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmochajs%2Fmocha?ref=badge_large) diff --git a/docs/API.md b/docs/API.md index 7b63a6b433..a6e17bf284 100644 --- a/docs/API.md +++ b/docs/API.md @@ -13,7 +13,7 @@ Otherwise, **you probably want the [main documentation](https://mochajs.org)**. ## Other Links - **[Main Documentation](https://mochajs.org)** -- **[Release Notes / History / Changes](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md)** -- [Code of Conduct](https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md) +- **[Release Notes / History / Changes](https://github.com/mochajs/mocha/blob/main/CHANGELOG.md)** +- [Code of Conduct](https://github.com/mochajs/mocha/blob/main/.github/CODE_OF_CONDUCT.md) - [Discord](https://discord.gg/KeDn2uXhER) (ask questions here!) - [Issue Tracker](https://github.com/mochajs/mocha/issues) diff --git a/docs/README.md b/docs/README.md index f85b53adec..0c3e69e53f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -40,6 +40,6 @@ cp: docs/_dist/_headers: No such file or directory :copyright: 2016-2018 [JS Foundation](https://js.foundation) and contributors. -Content licensed [CC-BY-4.0](https://raw.githubusercontent.com/mochajs/mocha/master/docs/LICENSE-CC-BY-4.0). +Content licensed [CC-BY-4.0](https://raw.githubusercontent.com/mochajs/mocha/main/docs/LICENSE-CC-BY-4.0). -Code licensed [MIT](https://raw.githubusercontent.com/mochajs/mocha/master/LICENSE-MIT). +Code licensed [MIT](https://raw.githubusercontent.com/mochajs/mocha/main/LICENSE-MIT). diff --git a/docs/api-tutorials/custom-reporter.md b/docs/api-tutorials/custom-reporter.md index 99ca9d6d2f..b537fe1ee2 100644 --- a/docs/api-tutorials/custom-reporter.md +++ b/docs/api-tutorials/custom-reporter.md @@ -13,7 +13,7 @@ If you're looking to get started quickly, here's an example of a custom reporter To use this reporter, execute `mocha --reporter /path/to/my-reporter.js`. -For further examples, the built-in reporter implementations are the [best place to look](https://github.com/mochajs/mocha/tree/master/lib/reporters). The [integration tests](https://github.com/mochajs/mocha/tree/master/test/reporters) may also be helpful. +For further examples, the built-in reporter implementations are the [best place to look](https://github.com/mochajs/mocha/tree/main/lib/reporters). The [integration tests](https://github.com/mochajs/mocha/tree/main/test/reporters) may also be helpful. ## The `Base` Reporter Class diff --git a/docs/changelogs/README.md b/docs/changelogs/README.md index 2c059575d2..1f201b251f 100644 --- a/docs/changelogs/README.md +++ b/docs/changelogs/README.md @@ -4,4 +4,4 @@ These are changelogs for (very) old versions of Mocha. These changelogs are _not_ included in the website, and are here only for archival purposes. -_If you're looking for the current changelog, [here is the current changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md)._ +_If you're looking for the current changelog, [here is the current changelog](https://github.com/mochajs/mocha/blob/main/CHANGELOG.md)._ diff --git a/docs/index.md b/docs/index.md index 4c71ef5fec..2e9313185d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2363,7 +2363,7 @@ $ npm test In addition to chatting with us on [our Discord][discord-mocha], for additional information such as using spies, mocking, and shared behaviours be sure to check out the [Mocha Wiki][mocha-wiki] on GitHub. For a running example of Mocha, view [example/tests.html](example/tests.html). For the JavaScript API, view the [API documentation](api/) -or the [source](https://github.com/mochajs/mocha/blob/master/lib/mocha.js). +or the [source](https://github.com/mochajs/mocha/blob/main/lib/mocha.js). [//]: # 'Cross reference section' [bash-globbing]: https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html @@ -2375,14 +2375,14 @@ or the [source](https://github.com/mochajs/mocha/blob/master/lib/mocha.js). [discord-mocha]: https://discord.gg/KeDn2uXhER [emacs]: https://www.gnu.org/software/emacs/ [emacs-mocha.el]: https://github.com/scottaj/mocha.el -[example-babel]: https://github.com/mochajs/mocha-examples/tree/master/packages/babel +[example-babel]: https://github.com/mochajs/mocha-examples/tree/main/packages/babel [example-connect-test]: https://github.com/senchalabs/connect/tree/master/test [example-express-test]: https://github.com/visionmedia/express/tree/master/test -[example-mocha-test]: https://github.com/mochajs/mocha/tree/master/test -[example-mocha-config]: https://github.com/mochajs/mocha/tree/master/example/config +[example-mocha-test]: https://github.com/mochajs/mocha/tree/main/test +[example-mocha-config]: https://github.com/mochajs/mocha/tree/main/example/config [example-superagent-test]: https://github.com/visionmedia/superagent/tree/master/test/node -[example-third-party-reporter]: https://github.com/mochajs/mocha-examples/tree/master/packages/third-party-reporter -[example-typescript]: https://github.com/mochajs/mocha-examples/tree/master/packages/typescript +[example-third-party-reporter]: https://github.com/mochajs/mocha-examples/tree/main/packages/third-party-reporter +[example-typescript]: https://github.com/mochajs/mocha-examples/tree/main/packages/typescript [example-websocket.io-test]: https://github.com/LearnBoost/websocket.io/tree/master/test [expect.js]: https://github.com/LearnBoost/expect.js [expresso]: https://github.com/tj/expresso From 12c88a75694f7e923114f6943a0dbd66302945c3 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 24 Jun 2024 13:36:58 -0400 Subject: [PATCH 18/34] Docs: add 10.5.0 to CHANGELOG.md --- CHANGELOG.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62a37eb7a8..46350a07ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 10.5.0 / 2024-05-24 + +### :tada: Enhancements + +* [#5015](https://github.com/mochajs/mocha/pull/5015) feat: use \ and \ for browser progress indicator instead of \ ([**@yourWaifu**](https://github.com/yourWaifu)) +* [#5143](https://github.com/mochajs/mocha/pull/5143) feat: allow using any 3.x chokidar dependencies ([**@simhnna**](https://github.com/simhnna)) +* [#4835](https://github.com/mochajs/mocha/pull/4835) feat: add MOCHA_OPTIONS env variable ([**@icholy**](https://github.com/icholy)) + +### :bug: Fixes + +* [#5107](https://github.com/mochajs/mocha/pull/5107) fix: include stack in browser uncaught error reporting ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) + +### :nut_and_bolt: Other + +* [#5110](https://github.com/mochajs/mocha/pull/5110) chore: switch two-column list styles to be opt-in ([**@marjys**](https://github.com/marjys)) +* [#5135](https://github.com/mochajs/mocha/pull/5135) chore: fix some typos in comments ([**@StevenMia**](https://github.com/StevenMia)) +* [#5130](https://github.com/mochajs/mocha/pull/5130) chore: rename 'master' to 'main' in docs and tooling ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) + ## 10.4.0 / 2024-03-26 ### :tada: Enhancements From b9ce511348e55adf721b55f836fcddfa81537735 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 24 Jun 2024 13:37:07 -0400 Subject: [PATCH 19/34] Release v10.5.0 --- AUTHORS | 5 ++ CHANGELOG.md | 120 +++++++++++++++++++++++----------------------- package-lock.json | 4 +- package.json | 2 +- 4 files changed, 68 insertions(+), 63 deletions(-) diff --git a/AUTHORS b/AUTHORS index 17d79bd2be..a872e5c109 100644 --- a/AUTHORS +++ b/AUTHORS @@ -554,5 +554,10 @@ Ville Lahdenvuo Nathan Phillip Brink Ståle Tomten dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> +Sleepy Flower +StevenMia <166844090+StevenMia@users.noreply.github.com> +Simon Hanna <33220646+simhnna@users.noreply.github.com> +Ilia Choly +Marjorie Saito # Generated by scripts/update-authors.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 46350a07ed..bc515e5d3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,19 +4,19 @@ ### :tada: Enhancements -* [#5015](https://github.com/mochajs/mocha/pull/5015) feat: use \ and \ for browser progress indicator instead of \ ([**@yourWaifu**](https://github.com/yourWaifu)) -* [#5143](https://github.com/mochajs/mocha/pull/5143) feat: allow using any 3.x chokidar dependencies ([**@simhnna**](https://github.com/simhnna)) -* [#4835](https://github.com/mochajs/mocha/pull/4835) feat: add MOCHA_OPTIONS env variable ([**@icholy**](https://github.com/icholy)) +- [#5015](https://github.com/mochajs/mocha/pull/5015) feat: use \ and \ for browser progress indicator instead of \ ([**@yourWaifu**](https://github.com/yourWaifu)) +- [#5143](https://github.com/mochajs/mocha/pull/5143) feat: allow using any 3.x chokidar dependencies ([**@simhnna**](https://github.com/simhnna)) +- [#4835](https://github.com/mochajs/mocha/pull/4835) feat: add MOCHA\_OPTIONS env variable ([**@icholy**](https://github.com/icholy)) ### :bug: Fixes -* [#5107](https://github.com/mochajs/mocha/pull/5107) fix: include stack in browser uncaught error reporting ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) +- [#5107](https://github.com/mochajs/mocha/pull/5107) fix: include stack in browser uncaught error reporting ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other -* [#5110](https://github.com/mochajs/mocha/pull/5110) chore: switch two-column list styles to be opt-in ([**@marjys**](https://github.com/marjys)) -* [#5135](https://github.com/mochajs/mocha/pull/5135) chore: fix some typos in comments ([**@StevenMia**](https://github.com/StevenMia)) -* [#5130](https://github.com/mochajs/mocha/pull/5130) chore: rename 'master' to 'main' in docs and tooling ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) +- [#5110](https://github.com/mochajs/mocha/pull/5110) chore: switch two-column list styles to be opt-in ([**@marjys**](https://github.com/marjys)) +- [#5135](https://github.com/mochajs/mocha/pull/5135) chore: fix some typos in comments ([**@StevenMia**](https://github.com/StevenMia)) +- [#5130](https://github.com/mochajs/mocha/pull/5130) chore: rename 'master' to 'main' in docs and tooling ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) ## 10.4.0 / 2024-03-26 @@ -29,7 +29,7 @@ - [#5074](https://github.com/mochajs/mocha/pull/5074) fix: harden error handling in `lib/cli/run.js` ([**@stalet**](https://github.com/stalet)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#5077](https://github.com/mochajs/mocha/pull/5077) chore: add mtfoley/pr-compliance-action ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) - [#5060](https://github.com/mochajs/mocha/pull/5060) chore: migrate ESLint config to flat config ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) @@ -54,7 +54,7 @@ This is a stable release equivalent to [10.30.0-prerelease](#1030-prerelease--20 This is a prerelease version to test our ability to release. Other than removing or updating dependencies, it contains no intended user-facing changes. -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#5069](https://github.com/mochajs/mocha/pull/5069): chore: remove unnecessary canvas dependency ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) - [#5068](https://github.com/mochajs/mocha/pull/5068): fix: add alt text to Built with Netlify badge ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) @@ -94,7 +94,7 @@ Other than removing or updating dependencies, it contains no intended user-facin - [#4896](https://github.com/mochajs/mocha/issues/4896): Browser: add support for `prefers-color-scheme: dark` ([**@greggman**](https://github.com/greggman)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4912](https://github.com/mochajs/mocha/issues/4912): Browser: increase contrast for replay buttons ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) - [#4905](https://github.com/mochajs/mocha/issues/4905): Use standard `Promise.allSettled` instead of polyfill ([**@outsideris**](https://github.com/outsideris)) @@ -119,7 +119,7 @@ Other than removing or updating dependencies, it contains no intended user-facin - [#4861](https://github.com/mochajs/mocha/issues/4861): Remove deprecated `Runner` signature ([**@juergba**](https://github.com/juergba)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4878](https://github.com/mochajs/mocha/issues/4878): Update production dependencies ([**@juergba**](https://github.com/juergba)) @@ -137,7 +137,7 @@ Also thanks to [**@ea2305**](https://github.com/ea2305) and [**@SukkaW**](https: - [#4839](https://github.com/mochajs/mocha/issues/4839): `dry-run`: prevent potential call-stack crash ([**@juergba**](https://github.com/juergba)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4843](https://github.com/mochajs/mocha/issues/4843): Update production dependencies ([**@juergba**](https://github.com/juergba)) @@ -155,7 +155,7 @@ Also thanks to [**@ea2305**](https://github.com/ea2305) and [**@SukkaW**](https: - [#4813](https://github.com/mochajs/mocha/issues/4813): Parallel: assign each worker a worker-id ([**@forty**](https://github.com/forty)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4818](https://github.com/mochajs/mocha/issues/4818): Update production dependencies ([**@juergba**](https://github.com/juergba)) @@ -165,7 +165,7 @@ Also thanks to [**@ea2305**](https://github.com/ea2305) and [**@SukkaW**](https: - [#4807](https://github.com/mochajs/mocha/issues/4807): `import` throws wrong error if loader is used ([**@giltayar**](https://github.com/giltayar)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4777](https://github.com/mochajs/mocha/issues/4777): Add Node v17 to CI test matrix ([**@outsideris**](https://github.com/outsideris)) @@ -175,7 +175,7 @@ Also thanks to [**@ea2305**](https://github.com/ea2305) and [**@SukkaW**](https: - [#4769](https://github.com/mochajs/mocha/issues/4769): Browser: re-enable `bdd` ES6 style import ([**@juergba**](https://github.com/juergba)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4764](https://github.com/mochajs/mocha/issues/4764): Revert deprecation of `EVENT_SUITE_ADD_*` events ([**@beatfactor**](https://github.com/beatfactor)) @@ -185,7 +185,7 @@ Also thanks to [**@ea2305**](https://github.com/ea2305) and [**@SukkaW**](https: - [#4746](https://github.com/mochajs/mocha/issues/4746): Browser: stop using all global vars in `browser-entry.js` ([**@PaperStrike**](https://github.com/PaperStrike)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4754](https://github.com/mochajs/mocha/issues/4754): Remove dependency wide-align ([**@juergba**](https://github.com/juergba)) - [#4736](https://github.com/mochajs/mocha/issues/4736): ESM: remove code for Node versions <10 ([**@juergba**](https://github.com/juergba)) @@ -220,13 +220,13 @@ Also thanks to [**@ea2305**](https://github.com/ea2305) and [**@SukkaW**](https: - [#4668](https://github.com/mochajs/mocha/issues/4668): ESM: make `--require ` work with new `import`-first loading ([**@giltayar**](https://github.com/giltayar)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4674](https://github.com/mochajs/mocha/issues/4674): Update production dependencies ([**@juergba**](https://github.com/juergba)) ## 9.0.1 / 2021-06-18 -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4657](https://github.com/mochajs/mocha/issues/4657): Browser: add separate bundle for modern browsers ([**@juergba**](https://github.com/juergba)) @@ -258,7 +258,7 @@ We added a separate browser bundle `mocha-es2018.js` in javascript ES2018, as we - [#4128](https://github.com/mochajs/mocha/issues/4128): Fix: control stringification of error message ([**@syeutyu**](https://github.com/syeutyu)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4646](https://github.com/mochajs/mocha/issues/4646): Deprecate `Runner(suite: Suite, delay: boolean)` signature ([**@juergba**](https://github.com/juergba)) - [#4643](https://github.com/mochajs/mocha/issues/4643): Update production dependencies ([**@juergba**](https://github.com/juergba)) @@ -318,7 +318,7 @@ Also thanks to [**@outsideris**](https://github.com/outsideris) for various impr - [#4503](https://github.com/mochajs/mocha/issues/4503): Add GH Actions workflow status badge ([**@outsideris**](https://github.com/outsideris)) - [#4494](https://github.com/mochajs/mocha/issues/4494): Add example of generating tests dynamically with a closure ([**@maxwellgerber**](https://github.com/maxwellgerber)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4556](https://github.com/mochajs/mocha/issues/4556): Upgrade all dependencies to latest stable ([**@AviVahl**](https://github.com/AviVahl)) - [#4543](https://github.com/mochajs/mocha/issues/4543): Update dependencies yargs and yargs-parser ([**@juergba**](https://github.com/juergba)) @@ -338,11 +338,11 @@ Also thanks to [**@akeating**](https://github.com/akeating) for a documentation ## 8.2.0 / 2020-10-16 -The major feature added in v8.2.0 is addition of support for [_global fixtures_](https://mochajs.org/#global-fixtures). +The major feature added in v8.2.0 is addition of support for [*global fixtures*](https://mochajs.org/#global-fixtures). -While Mocha has always had the ability to run setup and teardown via a hook (e.g., a `before()` at the top level of a test file) when running tests in serial, Mocha v8.0.0 added support for parallel runs. Parallel runs are _incompatible_ with this strategy; e.g., a top-level `before()` would only run for the file in which it was defined. +While Mocha has always had the ability to run setup and teardown via a hook (e.g., a `before()` at the top level of a test file) when running tests in serial, Mocha v8.0.0 added support for parallel runs. Parallel runs are *incompatible* with this strategy; e.g., a top-level `before()` would only run for the file in which it was defined. -With [global fixtures](https://mochajs.org/#global-fixtures), Mocha can now perform user-defined setup and teardown _regardless_ of mode, and these fixtures are guaranteed to run _once and only once_. This holds for parallel mode, serial mode, and even "watch" mode (the teardown will run once you hit Ctrl-C, just before Mocha finally exits). Tasks such as starting and stopping servers are well-suited to global fixtures, but not sharing resources--global fixtures do _not_ share context with your test files (but they do share context with each other). +With [global fixtures](https://mochajs.org/#global-fixtures), Mocha can now perform user-defined setup and teardown *regardless* of mode, and these fixtures are guaranteed to run *once and only once*. This holds for parallel mode, serial mode, and even "watch" mode (the teardown will run once you hit Ctrl-C, just before Mocha finally exits). Tasks such as starting and stopping servers are well-suited to global fixtures, but not sharing resources--global fixtures do *not* share context with your test files (but they do share context with each other). Here's a short example of usage: @@ -377,7 +377,7 @@ For detailed information, please see the [documentation](https://mochajs.org/#gl - [#4434](https://github.com/mochajs/mocha/issues/4434): Output of `json` reporter now contains `speed` ("fast"/"medium"/"slow") property ([**@wwhurin**](https://github.com/wwhurin)) - [#4464](https://github.com/mochajs/mocha/issues/4464): Errors thrown by serializer in parallel mode now have error codes ([**@evaline-ju**](https://github.com/evaline-ju)) -_For implementors of custom reporters:_ +*For implementors of custom reporters:* - [#4409](https://github.com/mochajs/mocha/issues/4409): Parallel mode and custom reporter improvements ([**@boneskull**](https://github.com/boneskull)): - Support custom worker-process-only reporters (`Runner.prototype.workerReporter()`); reporters should subclass `ParallelBufferedReporter` in `mocha/lib/nodejs/reporters/parallel-buffered` @@ -423,11 +423,11 @@ Thanks to [**@AviVahl**](https://github.com/AviVahl), [**@donghoon-song**](https In this release, Mocha now builds its browser bundle with Rollup and Babel, which will provide the project's codebase more flexibility and consistency. -While we've been diligent about backwards compatibility, it's _possible_ consumers of the browser bundle will encounter differences (other than an increase in the bundle size). If you _do_ encounter an issue with the build, please [report it here](https://github.com/mochajs/mocha/issues/new?labels=unconfirmed-bug&template=bug_report.md&title=). +While we've been diligent about backwards compatibility, it's *possible* consumers of the browser bundle will encounter differences (other than an increase in the bundle size). If you *do* encounter an issue with the build, please [report it here](https://github.com/mochajs/mocha/issues/new?labels=unconfirmed-bug\&template=bug_report.md\&title=). This release **does not** drop support for IE11. -Other community contributions came from [**@Devjeel**](https://github.com/Devjeel), [**@Harsha509**](https://github.com/Harsha509) and [**@sharath2106**](https://github.com/sharath2106). _Thank you_ to everyone who contributed to this release! +Other community contributions came from [**@Devjeel**](https://github.com/Devjeel), [**@Harsha509**](https://github.com/Harsha509) and [**@sharath2106**](https://github.com/sharath2106). *Thank you* to everyone who contributed to this release! > Do you read Korean? See [this guide to running parallel tests in Mocha](https://blog.outsider.ne.kr/1489), translated by our maintainer, [**@outsideris**](https://github.com/outsideris). @@ -454,7 +454,7 @@ Other community contributions came from [**@Devjeel**](https://github.com/Devjee - [#4343](https://github.com/mochajs/mocha/issues/4343): Clean up some API docs ([**@craigtaub**](https://github.com/craigtaub)) - [#4318](https://github.com/mochajs/mocha/issues/4318): Sponsor images are now self-hosted ([**@Munter**](https://github.com/Munter)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4293](https://github.com/mochajs/mocha/issues/4293): Use Rollup and Babel in build pipeline; add source map to published files ([**@Munter**](https://github.com/Munter)) @@ -468,7 +468,7 @@ The obligatory patch after a major. ## 8.0.0 / 2020-06-10 -In this major release, Mocha adds the ability to _run tests in parallel_. Better late than never! Please note the **breaking changes** detailed below. +In this major release, Mocha adds the ability to *run tests in parallel*. Better late than never! Please note the **breaking changes** detailed below. Let's welcome [**@giltayar**](https://github.com/giltayar) and [**@nicojs**](https://github.com/nicojs) to the maintenance team! @@ -505,17 +505,17 @@ Let's welcome [**@giltayar**](https://github.com/giltayar) and [**@nicojs**](htt - [#4245](https://github.com/mochajs/mocha/issues/4245): Add ability to run tests in parallel for Node.js (see [docs](https://mochajs.org/#parallel-tests)) ([**@boneskull**](https://github.com/boneskull)) - :exclamation: See also [#4244](https://github.com/mochajs/mocha/issues/4244); [Root Hook Plugins (docs)](https://mochajs.org/#root-hook-plugins) -- _root hooks must be defined via Root Hook Plugins to work in parallel mode_ + :exclamation: See also [#4244](https://github.com/mochajs/mocha/issues/4244); [Root Hook Plugins (docs)](https://mochajs.org/#root-hook-plugins) -- *root hooks must be defined via Root Hook Plugins to work in parallel mode* - [#4304](https://github.com/mochajs/mocha/issues/4304): `--require` now works with ES modules ([**@JacobLey**](https://github.com/JacobLey)) -- [#4299](https://github.com/mochajs/mocha/issues/4299): In some circumstances, Mocha can run ES modules under Node.js v10 -- _use at your own risk!_ ([**@giltayar**](https://github.com/giltayar)) +- [#4299](https://github.com/mochajs/mocha/issues/4299): In some circumstances, Mocha can run ES modules under Node.js v10 -- *use at your own risk!* ([**@giltayar**](https://github.com/giltayar)) ### :book: Documentation - [#4246](https://github.com/mochajs/mocha/issues/4246): Add documentation for parallel mode and Root Hook plugins ([**@boneskull**](https://github.com/boneskull)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4200](https://github.com/mochajs/mocha/issues/4200): Drop mkdirp and replace it with fs.mkdirSync ([**@HyunSangHan**](https://github.com/HyunSangHan)) @@ -547,7 +547,7 @@ Let's welcome [**@giltayar**](https://github.com/giltayar) and [**@nicojs**](htt - [#4235](https://github.com/mochajs/mocha/issues/4235): Enable emoji on website; enable normal ul elements ([**@boneskull**](https://github.com/boneskull)) - [#4272](https://github.com/mochajs/mocha/issues/4272): Fetch sponsors at build time, show ALL non-skeevy sponsors ([**@boneskull**](https://github.com/boneskull)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4249](https://github.com/mochajs/mocha/issues/4249): Refactoring improving encapsulation ([**@arvidOtt**](https://github.com/arvidOtt)) - [#4242](https://github.com/mochajs/mocha/issues/4242): CI add job names, add Node.js v14 to matrix ([**@boneskull**](https://github.com/boneskull)) @@ -556,7 +556,7 @@ Let's welcome [**@giltayar**](https://github.com/giltayar) and [**@nicojs**](htt ## 7.1.2 / 2020-04-26 -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4251](https://github.com/mochajs/mocha/issues/4251): Prevent karma-mocha from stalling ([**@juergba**](https://github.com/juergba)) - [#4222](https://github.com/mochajs/mocha/issues/4222): Update dependency mkdirp to v0.5.5 ([**@outsideris**](https://github.com/outsideris)) @@ -603,7 +603,7 @@ Mocha supports writing your test files as ES modules: - [#4058](https://github.com/mochajs/mocha/issues/4058): Manage author list in AUTHORS instead of `package.json` ([**@outsideris**](https://github.com/outsideris)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4138](https://github.com/mochajs/mocha/issues/4138): Upgrade ESLint v6.8 ([**@kaicataldo**](https://github.com/kaicataldo)) @@ -621,7 +621,7 @@ Mocha supports writing your test files as ES modules: - [#4146](https://github.com/mochajs/mocha/issues/4146): Update copyright & trademark notices per OJSF ([**@boneskull**](https://github.com/boneskull)) - [#4140](https://github.com/mochajs/mocha/issues/4140): Fix broken links ([**@KyoungWan**](https://github.com/KyoungWan)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4133](https://github.com/mochajs/mocha/issues/4133): Print more descriptive error message ([**@Zirak**](https://github.com/Zirak)) @@ -651,7 +651,7 @@ Mocha supports writing your test files as ES modules: ### :fax: Deprecations -These are _soft_-deprecated, and will emit a warning upon use. Support will be removed in (likely) the next major version of Mocha: +These are *soft*-deprecated, and will emit a warning upon use. Support will be removed in (likely) the next major version of Mocha: - [#3968](https://github.com/mochajs/mocha/issues/3968): Deprecate legacy configuration via `mocha.opts` ([**@juergba**](https://github.com/juergba)) @@ -677,7 +677,7 @@ These are _soft_-deprecated, and will emit a warning upon use. Support will be r - [#4045](https://github.com/mochajs/mocha/issues/4045): Update README.md concerning GraphicsMagick installation ([**@HyunSangHan**](https://github.com/HyunSangHan)) - [#3988](https://github.com/mochajs/mocha/issues/3988): Fix sponsors background color for readability ([**@outsideris**](https://github.com/outsideris)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#4118](https://github.com/mochajs/mocha/issues/4118): Update node-environment-flags to 1.0.6 ([**@kylef**](https://github.com/kylef)) - [#4097](https://github.com/mochajs/mocha/issues/4097): Add GH Funding Metadata ([**@SheetJSDev**](https://github.com/SheetJSDev)) @@ -709,7 +709,7 @@ These are _soft_-deprecated, and will emit a warning upon use. Support will be r ### :bug: Fixes -- [#3955](https://github.com/mochajs/mocha/issues/3955): tty.getWindowSize is not a function inside a "worker_threads" worker ([**@1999**](https://github.com/1999)) +- [#3955](https://github.com/mochajs/mocha/issues/3955): tty.getWindowSize is not a function inside a "worker\_threads" worker ([**@1999**](https://github.com/1999)) - [#3970](https://github.com/mochajs/mocha/issues/3970): remove extraGlobals() ([**@juergba**](https://github.com/juergba)) - [#3984](https://github.com/mochajs/mocha/issues/3984): Update yargs-unparser to v1.6.0 ([**@juergba**](https://github.com/juergba)) - [#3983](https://github.com/mochajs/mocha/issues/3983): Package 'esm': spawn child-process for correct loading ([**@juergba**](https://github.com/juergba)) @@ -748,7 +748,7 @@ These are _soft_-deprecated, and will emit a warning upon use. Support will be r - [#3915](https://github.com/mochajs/mocha/issues/3915), [#3929](https://github.com/mochajs/mocha/issues/3929): Increase tests coverage for `--watch` options ([**@geigerzaehler**](https://github.com/geigerzaehler)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#3953](https://github.com/mochajs/mocha/issues/3953): Collect test files later, prepares improvements to the `--watch` mode behavior ([**@geigerzaehler**](https://github.com/geigerzaehler)) - [#3939](https://github.com/mochajs/mocha/issues/3939): Upgrade for npm audit ([**@boneskull**](https://github.com/boneskull)) @@ -800,7 +800,7 @@ These are _soft_-deprecated, and will emit a warning upon use. Support will be r ### :fax: Deprecations -These are _soft_-deprecated, and will emit a warning upon use. Support will be removed in (likely) the next major version of Mocha: +These are *soft*-deprecated, and will emit a warning upon use. Support will be removed in (likely) the next major version of Mocha: - [#3719](https://github.com/mochajs/mocha/issues/3719): Deprecate `this.skip()` for "after all" hooks ([**@juergba**](https://github.com/juergba)) @@ -826,7 +826,7 @@ and some regressions: - [#3807](https://github.com/mochajs/mocha/issues/3807): Mocha website HTML tweaks ([**@plroebuck**](https://github.com/plroebuck)) - [#3793](https://github.com/mochajs/mocha/issues/3793): Update config file example ".mocharc.yml" ([**@cspotcode**](https://github.com/cspotcode)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#3830](https://github.com/mochajs/mocha/issues/3830): Replace dependency "findup-sync" with "find-up" for faster startup ([**@cspotcode**](https://github.com/cspotcode)) - [#3799](https://github.com/mochajs/mocha/issues/3799): Update devDependencies to fix many npm vulnerabilities ([**@XhmikosR**](https://github.com/XhmikosR)) @@ -851,7 +851,7 @@ These issues were regressions. - [#3754](https://github.com/mochajs/mocha/issues/3754): Mocha again finds `test.js` when run without arguments ([**@plroebuck**](https://github.com/plroebuck)) - [#3756](https://github.com/mochajs/mocha/issues/3756): Mocha again supports third-party interfaces via `--ui` ([**@boneskull**](https://github.com/boneskull)) - [#3755](https://github.com/mochajs/mocha/issues/3755): Fix broken `--watch` ([**@boneskull**](https://github.com/boneskull)) -- [#3759](https://github.com/mochajs/mocha/issues/3759): Fix unwelcome deprecation notice when Mocha run against languages (CoffeeScript) with implicit return statements; _returning a non-`undefined` value from a `describe` callback is no longer considered deprecated_ ([**@boneskull**](https://github.com/boneskull)) +- [#3759](https://github.com/mochajs/mocha/issues/3759): Fix unwelcome deprecation notice when Mocha run against languages (CoffeeScript) with implicit return statements; *returning a non-`undefined` value from a `describe` callback is no longer considered deprecated* ([**@boneskull**](https://github.com/boneskull)) ### :book: Documentation @@ -887,7 +887,7 @@ These issues were regressions. - [#3652](https://github.com/mochajs/mocha/issues/3652): Switch from Jekyll to Eleventy ([**@Munter**](https://github.com/Munter)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#3677](https://github.com/mochajs/mocha/issues/3677): Add error objects for createUnsupportedError and createInvalidExceptionError ([**@boneskull**](https://github.com/boneskull)) - [#3733](https://github.com/mochajs/mocha/issues/3733): Removed unnecessary processing in post-processing hook ([**@wanseob**](https://github.com/wanseob)) @@ -917,7 +917,7 @@ Welcome [**@plroebuck**](https://github.com/plroebuck), [**@craigtaub**](https:/ - `-d` is no longer an alias for `--debug`; `-d` is currently ignored - [#3275](https://github.com/mochajs/mocha/issues/3275): `--watch-extensions` no longer implies `js`; it must be explicitly added ([**@TheDancingCode**](https://github.com/TheDancingCode)) - [#2908](https://github.com/mochajs/mocha/issues/2908): `tap` reporter emits error messages ([**@chrmod**](https://github.com/chrmod)) -- [#2819](https://github.com/mochajs/mocha/issues/2819): When conditionally skipping in a `before` hook, subsequent `before` hooks _and_ tests in nested suites are now skipped ([**@bannmoore**](https://github.com/bannmoore)) +- [#2819](https://github.com/mochajs/mocha/issues/2819): When conditionally skipping in a `before` hook, subsequent `before` hooks *and* tests in nested suites are now skipped ([**@bannmoore**](https://github.com/bannmoore)) - [#627](https://github.com/mochajs/mocha/issues/627): Emit filepath in "timeout exceeded" exceptions where applicable ([**@boneskull**](https://github.com/boneskull)) - [#3556](https://github.com/mochajs/mocha/issues/3556): `lib/template.html` has moved to `lib/browser/template.html` ([**@boneskull**](https://github.com/boneskull)) - [#2576](https://github.com/mochajs/mocha/issues/2576): An exception is now thrown if Mocha fails to parse or find a `mocha.opts` at a user-specified path ([**@plroebuck**](https://github.com/plroebuck)) @@ -926,7 +926,7 @@ Welcome [**@plroebuck**](https://github.com/plroebuck), [**@craigtaub**](https:/ ### :fax: Deprecations -These are _soft_-deprecated, and will emit a warning upon use. Support will be removed in (likely) the next major version of Mocha: +These are *soft*-deprecated, and will emit a warning upon use. Support will be removed in (likely) the next major version of Mocha: - `-gc` users should use `--gc-global` instead - Consumers of the function exported by `bin/options` should now use the `loadMochaOpts` or `loadOptions` (preferred) functions exported by the `lib/cli/options` module @@ -963,7 +963,7 @@ Enhancements introduced in [#3556](https://github.com/mochajs/mocha/issues/3556) - Support all allowed `node` flags as supported by the running version of `node` (also thanks to [**@demurgos**](https://github.com/demurgos)) - Support any V8 flag by prepending `--v8-` to the flag name - All flags are also supported via config files, `package.json` properties, or `mocha.opts` - - Debug-related flags (e.g., `--inspect`) now _imply_ `--no-timeouts` + - Debug-related flags (e.g., `--inspect`) now *imply* `--no-timeouts` - Use of e.g., `--debug` will automatically invoke `--inspect` if supported by running version of `node` - Support negation of any Mocha-specific command-line flag by prepending `--no-` to the flag name @@ -972,7 +972,7 @@ Enhancements introduced in [#3556](https://github.com/mochajs/mocha/issues/3556) - `Mocha` constructor supports all options -- `--extension` is now an alias for `--watch-extensions` and affects _non-watch-mode_ test runs as well. For example, to run _only_ `test/*.coffee` (not `test/*.js`), you can do `mocha --require coffee-script/register --extensions coffee`. +- `--extension` is now an alias for `--watch-extensions` and affects *non-watch-mode* test runs as well. For example, to run *only* `test/*.coffee` (not `test/*.js`), you can do `mocha --require coffee-script/register --extensions coffee`. - [#3552](https://github.com/mochajs/mocha/issues/3552): `tap` reporter is now TAP13-capable ([**@plroebuck**](https://github.com/plroebuck) & [**@mollstam**](https://github.com/mollstam)) @@ -1010,7 +1010,7 @@ Enhancements introduced in [#3556](https://github.com/mochajs/mocha/issues/3556) - [#2819](https://github.com/mochajs/mocha/issues/2819): Update docs around skips and hooks ([**@bannmoore**](https://github.com/bannmoore)) - Many improvements by [**@outsideris**](https://github.com/outsideris) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#3557](https://github.com/mochajs/mocha/issues/3557): Use `ms` userland module instead of hand-rolled solution ([**@gizemkeser**](https://github.com/gizemkeser)) - Many CI fixes and other refactors by [**@plroebuck**](https://github.com/plroebuck) @@ -1030,7 +1030,7 @@ Enhancements introduced in [#3556](https://github.com/mochajs/mocha/issues/3556) - [#3328](https://github.com/mochajs/mocha/pull/3328): Mocha-flavored [API docs](https://mochajs.org/api/)! ([@Munter](https://github.com/munter)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#3330](https://github.com/mochajs/mocha/pull/3330): Use `Buffer.from()` ([@harrysarson](https://github.com/harrysarson)) - [#3295](https://github.com/mochajs/mocha/pull/3295): Remove redundant folder ([@DavNej](https://github.com/DajNev)) @@ -1057,7 +1057,7 @@ Enhancements introduced in [#3556](https://github.com/mochajs/mocha/issues/3556) - [#3323](https://github.com/mochajs/mocha/pull/3323): Publish actual [API documentation](https://mochajs.org/api/)! ([@dfberry](https://github.com/dfberry), [@Munter](https://github.com/munter)) - [#3299](https://github.com/mochajs/mocha/pull/3299): Improve docs around exclusive tests ([@nicgirault](https://github.com/nicgirault)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#3302](https://github.com/mochajs/mocha/pull/3302), [#3308](https://github.com/mochajs/mocha/pull/3308), [#3310](https://github.com/mochajs/mocha/pull/3310), [#3315](https://github.com/mochajs/mocha/pull/3315), [#3316](https://github.com/mochajs/mocha/pull/3316): Build matrix improvements ([more info](https://boneskull.com/mocha-and-travis-ci-build-stages/)) ([@outsideris](https://github.com/outsideris), [@boneskull](https://github.com/boneskull)) - [#3272](https://github.com/mochajs/mocha/pull/3272): Refactor reporter tests ([@jMuzsik](https://github.com/jMuzsik)) @@ -1076,7 +1076,7 @@ Welcome [@outsideris](https://github.com/outsideris) to the team! - [#3133](https://github.com/mochajs/mocha/issues/3133): Improve docs regarding "pending" behavior ([@ematicipo](https://github.com/ematicipo)) - [#3276](https://github.com/mochajs/mocha/pull/3276), [#3274](https://github.com/mochajs/mocha/pull/3274): Fix broken stuff in `CHANGELOG.md` ([@tagoro9](https://github.com/tagoro9), [@honzajavorek](https://github.com/honzajavorek)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#3208](https://github.com/mochajs/mocha/issues/3208): Improve test coverage for AMD users ([@outsideris](https://github.com/outsideris)) - [#3267](https://github.com/mochajs/mocha/pull/3267): Remove vestiges of PhantomJS from CI ([@anishkny](https://github.com/anishkny)) @@ -1096,13 +1096,13 @@ This patch features a fix to address a potential "low severity" [ReDoS vulnerabi - [#3266](https://github.com/mochajs/mocha/pull/3266): Bump `diff` to v3.5.0 ([@anishkny](https://github.com/anishkny)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#3011](https://github.com/mochajs/mocha/issues/3011): Expose `generateDiff()` in `Base` reporter ([@harrysarson](https://github.com/harrysarson)) ## 5.0.2 / 2018-03-05 -This release fixes a class of tests which report as _false positives_. **Certain tests will now break**, though they would have previously been reported as passing. Details below. Sorry for the inconvenience! +This release fixes a class of tests which report as *false positives*. **Certain tests will now break**, though they would have previously been reported as passing. Details below. Sorry for the inconvenience! ### :bug: Fixes @@ -1123,13 +1123,13 @@ This release fixes a class of tests which report as _false positives_. **Certain }); \`\`\` - Previously to this version, Mocha would have _silently swallowed_ the `chaos!` exception, and you wouldn't know. Well, _now you know_. Mocha cannot recover from this gracefully, so it will exit with a nonzero code. + Previously to this version, Mocha would have *silently swallowed* the `chaos!` exception, and you wouldn't know. Well, *now you know*. Mocha cannot recover from this gracefully, so it will exit with a nonzero code. - **Maintainers of external reporters**: _If_ a test of this class is encountered, the `Runner` instance will emit the `end` event _twice_; you _may_ need to change your reporter to use `runner.once('end')` intead of `runner.on('end')`. + **Maintainers of external reporters**: *If* a test of this class is encountered, the `Runner` instance will emit the `end` event *twice*; you *may* need to change your reporter to use `runner.once('end')` intead of `runner.on('end')`. - [#3093](https://github.com/mochajs/mocha/issues/3093): Fix stack trace reformatting problem ([@outsideris](https://github.com/outsideris)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#3248](https://github.com/mochajs/mocha/issues/3248): Update `browser-stdout` to v1.3.1 ([@honzajavorek](https://github.com/honzajavorek)) @@ -1150,14 +1150,14 @@ Special thanks to [Wallaby.js](https://wallabyjs.com) for their continued suppor - [#3212](https://github.com/mochajs/mocha/pull/3212): Update [Wallaby.js](https://wallabyjs.com)-related docs ([@ArtemGovorov](https://github.com/ArtemGovorov)) - [#3205](https://github.com/mochajs/mocha/pull/3205): Remove outdated cruft ([@boneskull](https://github.com/boneskull)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#3224](https://github.com/mochajs/mocha/pull/3224): Add proper Wallaby.js config ([@ArtemGovorov](https://github.com/ArtemGovorov)) - [#3230](https://github.com/mochajs/mocha/pull/3230): Update copyright year ([@josephlin55555](https://github.com/josephlin55555)) ## 5.0.0 / 2018-01-17 -Mocha starts off 2018 right by again dropping support for _unmaintained rubbish_. +Mocha starts off 2018 right by again dropping support for *unmaintained rubbish*. Welcome [@vkarpov15](https://github.com/vkarpov15) to the team! @@ -1188,7 +1188,7 @@ Welcome [@vkarpov15](https://github.com/vkarpov15) to the team! - [#3177](https://github.com/mochajs/mocha/pull/3177): Tweak `README.md` organization ([@xxczaki](https://github.com/xxczaki)) - Misc updates ([@boneskull](https://github.com/boneskull)) -### :nut_and_bolt: Other +### :nut\_and\_bolt: Other - [#3118](https://github.com/mochajs/mocha/issues/3118): Move TextMate Integration to [its own repo](https://github.com/mochajs/mocha.tmbundle) ([@Bamieh](https://github.com/Bamieh)) - [#3185](https://github.com/mochajs/mocha/issues/3185): Add Node.js v9 to build matrix; remove v7 ([@xxczaki](https://github.com/xxczaki)) diff --git a/package-lock.json b/package-lock.json index 7d5c3379ac..d9e2b95f89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mocha", - "version": "10.4.0", + "version": "10.5.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mocha", - "version": "10.4.0", + "version": "10.5.0", "license": "MIT", "dependencies": { "ansi-colors": "4.1.1", diff --git a/package.json b/package.json index f4fcf530e5..04adfa1d54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mocha", - "version": "10.4.0", + "version": "10.5.0", "type": "commonjs", "description": "simple, flexible, fun test framework", "keywords": [ From dbe229d1b7ce672a02992b12ecb38a1cdd440a1e Mon Sep 17 00:00:00 2001 From: Khoa Huynh <58313491+khoaHyh@users.noreply.github.com> Date: Tue, 25 Jun 2024 02:17:32 -0400 Subject: [PATCH 20/34] fix: Add error handling for nonexistent file case with --file option (#5086) * feat: handle nonexistent files passed to --file - added error handling when using the --file flag to do it the way --require does - added a test to assert that we throw the same type of error * refactor: remove path.resolve() - require.resolve() by Node.js follows a Node.js module resolution algo which includes checking if the resolved path actually exists on the file system. * add comment to new code in collect-files.js * fix: add back absolute path resolving * refactor: log warning and remove call stack * revert changes to bin/mocha.js * improve test case * throw error and have handler work with it * change collectFiles to return object * clean up * exit mocha immediately on missing file * new log message * add tests * code quality improvements * add comments * docs: update to new link name * pass mocha instance to helper function --------- Co-authored-by: Pelle Wessman --- docs/index.md | 4 +- lib/cli/collect-files.js | 56 ++++++++++-- lib/cli/run-helpers.js | 53 ++++++++++-- lib/cli/watch-run.js | 4 +- .../fixtures/collect-files.fixture.mjs | 7 ++ test/integration/options/file.spec.js | 86 ++++++++++++++++++- 6 files changed, 190 insertions(+), 20 deletions(-) create mode 100644 test/integration/fixtures/collect-files.fixture.mjs diff --git a/docs/index.md b/docs/index.md index 2e9313185d..bf9c12fd23 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1063,7 +1063,7 @@ The option can be given multiple times. The option accepts a comma-delimited lis `--extension` now supports multipart extensions (e.g., `spec.js`), leading dots (`.js`) and combinations thereof (`.spec.js`); -### `--file ` +### `--file ` > _WARNING: `--file` is incompatible with [parallel mode](#parallel-tests)._ @@ -1298,7 +1298,7 @@ In parallel mode, Mocha does not guarantee the order in which test files will ru Because of this, the following options, which depend on order, _cannot be used_ in parallel mode: -- [`--file`](#-file-filedirectoryglob) +- [`--file`](#-file-file) - [`--sort`](#-sort-s) - [`--delay`](#delayed-root-suite) {:.single-column} diff --git a/lib/cli/collect-files.js b/lib/cli/collect-files.js index cc04559443..73f5d2e95a 100644 --- a/lib/cli/collect-files.js +++ b/lib/cli/collect-files.js @@ -1,5 +1,6 @@ 'use strict'; +const fs = require('fs'); const path = require('path'); const ansi = require('ansi-colors'); const debug = require('debug')('mocha:cli:run:helpers'); @@ -19,7 +20,7 @@ const {castArray} = require('../utils'); /** * Smash together an array of test files in the correct order * @param {FileCollectionOptions} [opts] - Options - * @returns {string[]} List of files to test + * @returns {FileCollectionResponse} An object containing a list of files to test and unmatched files. * @private */ module.exports = ({ @@ -30,7 +31,7 @@ module.exports = ({ sort, spec } = {}) => { - const unmatched = []; + const unmatchedSpecFiles = []; const specFiles = spec.reduce((specFiles, arg) => { try { const moreSpecFiles = castArray(lookupFiles(arg, extension, recursive)) @@ -44,7 +45,7 @@ module.exports = ({ return [...specFiles, ...moreSpecFiles]; } catch (err) { if (err.code === NO_FILES_MATCH_PATTERN) { - unmatched.push({message: err.message, pattern: err.pattern}); + unmatchedSpecFiles.push({message: err.message, pattern: err.pattern}); return specFiles; } @@ -52,6 +53,27 @@ module.exports = ({ } }, []); + // check that each file passed in to --file exists + + const unmatchedFiles = []; + fileArgs.forEach(file => { + const fileAbsolutePath = path.resolve(file); + try { + // Used instead of fs.existsSync to ensure that file-ending less files are still resolved correctly + require.resolve(fileAbsolutePath); + } catch (err) { + if (err.code === 'MODULE_NOT_FOUND') { + unmatchedFiles.push({ + pattern: file, + absolutePath: fileAbsolutePath + }); + return; + } + + throw err; + } + }); + // ensure we don't sort the stuff from fileArgs; order is important! if (sort) { specFiles.sort(); @@ -67,19 +89,24 @@ module.exports = ({ if (!files.length) { // give full message details when only 1 file is missing const noneFoundMsg = - unmatched.length === 1 - ? `Error: No test files found: ${JSON.stringify(unmatched[0].pattern)}` // stringify to print escaped characters raw + unmatchedSpecFiles.length === 1 + ? `Error: No test files found: ${JSON.stringify( + unmatchedSpecFiles[0].pattern + )}` // stringify to print escaped characters raw : 'Error: No test files found'; console.error(ansi.red(noneFoundMsg)); process.exit(1); } else { // print messages as a warning - unmatched.forEach(warning => { + unmatchedSpecFiles.forEach(warning => { console.warn(ansi.yellow(`Warning: ${warning.message}`)); }); } - return files; + return { + files, + unmatchedFiles + }; }; /** @@ -93,3 +120,18 @@ module.exports = ({ * @property {boolean} recursive - Find files recursively * @property {boolean} sort - Sort test files */ + +/** + * Diagnostic object containing unmatched files + * @typedef {Object} UnmatchedFile - + * @property {string} absolutePath - A list of unmatched files derived from the file arguments passed in. + * @property {string} pattern - A list of unmatched files derived from the file arguments passed in. + * + */ + +/** + * Response object containing a list of files to test and unmatched files. + * @typedef {Object} FileCollectionResponse + * @property {string[]} files - A list of files to test + * @property {UnmatchedFile[]} unmatchedFiles - A list of unmatched files derived from the file arguments passed in. + */ diff --git a/lib/cli/run-helpers.js b/lib/cli/run-helpers.js index 078ca7e434..0d01afbf11 100644 --- a/lib/cli/run-helpers.js +++ b/lib/cli/run-helpers.js @@ -9,6 +9,7 @@ const fs = require('fs'); const path = require('path'); +const ansi = require('ansi-colors'); const debug = require('debug')('mocha:cli:run:helpers'); const {watchRun, watchParallelRun} = require('./watch-run'); const collectFiles = require('./collect-files'); @@ -16,6 +17,7 @@ const {format} = require('util'); const {createInvalidLegacyPluginError} = require('../errors'); const {requireOrImport} = require('../nodejs/esm-utils'); const PluginLoader = require('../plugin-loader'); +const {UnmatchedFile} = require('./collect-files'); /** * Exits Mocha when tests + code under test has finished execution (default) @@ -106,6 +108,32 @@ exports.handleRequires = async (requires = [], {ignoredPlugins = []} = {}) => { return plugins; }; +/** + * Logs errors and exits the app if unmatched files exist + * @param {Mocha} mocha - Mocha instance + * @param {UnmatchedFile} unmatchedFiles - object containing unmatched file paths + * @returns {Promise} + * @private + */ +const handleUnmatchedFiles = (mocha, unmatchedFiles) => { + if (unmatchedFiles.length === 0) { + return; + } + + unmatchedFiles.forEach(({pattern, absolutePath}) => { + console.error( + ansi.yellow( + `Warning: Cannot find any files matching pattern "${pattern}" at the absolute path "${absolutePath}"` + ) + ); + }); + console.log( + 'No test file(s) found with the given pattern, exiting with code 1' + ); + + return mocha.run(exitMocha(1)); +}; + /** * Collect and load test files, then run mocha instance. * @param {Mocha} mocha - Mocha instance @@ -117,9 +145,14 @@ exports.handleRequires = async (requires = [], {ignoredPlugins = []} = {}) => { * @private */ const singleRun = async (mocha, {exit}, fileCollectParams) => { - const files = collectFiles(fileCollectParams); - debug('single run with %d file(s)', files.length); - mocha.files = files; + const fileCollectionObj = collectFiles(fileCollectParams); + + if (fileCollectionObj.unmatchedFiles.length > 0) { + return handleUnmatchedFiles(mocha, fileCollectionObj.unmatchedFiles); + } + + debug('single run with %d file(s)', fileCollectionObj.files.length); + mocha.files = fileCollectionObj.files; // handles ESM modules await mocha.loadFilesAsync(); @@ -140,9 +173,17 @@ const singleRun = async (mocha, {exit}, fileCollectParams) => { * @private */ const parallelRun = async (mocha, options, fileCollectParams) => { - const files = collectFiles(fileCollectParams); - debug('executing %d test file(s) in parallel mode', files.length); - mocha.files = files; + const fileCollectionObj = collectFiles(fileCollectParams); + + if (fileCollectionObj.unmatchedFiles.length > 0) { + return handleUnmatchedFiles(mocha, fileCollectionObj.unmatchedFiles); + } + + debug( + 'executing %d test file(s) in parallel mode', + fileCollectionObj.files.length + ); + mocha.files = fileCollectionObj.files; // note that we DO NOT load any files here; this is handled by the worker return mocha.run(options.exit ? exitMocha : exitMochaLater); diff --git a/lib/cli/watch-run.js b/lib/cli/watch-run.js index a77ed7a91a..6d5c6c26a7 100644 --- a/lib/cli/watch-run.js +++ b/lib/cli/watch-run.js @@ -58,7 +58,7 @@ exports.watchParallelRun = ( newMocha.suite.ctx = new Context(); // reset the list of files - newMocha.files = collectFiles(fileCollectParams); + newMocha.files = collectFiles(fileCollectParams).files; // because we've swapped out the root suite (see the `run` inner function // in `createRerunner`), we need to call `mocha.ui()` again to set up the context/globals. @@ -120,7 +120,7 @@ exports.watchRun = (mocha, {watchFiles, watchIgnore}, fileCollectParams) => { newMocha.suite.ctx = new Context(); // reset the list of files - newMocha.files = collectFiles(fileCollectParams); + newMocha.files = collectFiles(fileCollectParams).files; // because we've swapped out the root suite (see the `run` inner function // in `createRerunner`), we need to call `mocha.ui()` again to set up the context/globals. diff --git a/test/integration/fixtures/collect-files.fixture.mjs b/test/integration/fixtures/collect-files.fixture.mjs new file mode 100644 index 0000000000..199e9714ac --- /dev/null +++ b/test/integration/fixtures/collect-files.fixture.mjs @@ -0,0 +1,7 @@ +var obj = {foo: 'bar'}; + +describe('mjs', function () { + it('should work', function () { + expect(obj, 'to equal', {foo: 'bar'}); + }); +}); diff --git a/test/integration/options/file.spec.js b/test/integration/options/file.spec.js index 88815376f0..259ce4782e 100644 --- a/test/integration/options/file.spec.js +++ b/test/integration/options/file.spec.js @@ -1,9 +1,11 @@ 'use strict'; var path = require('path').posix; -var helpers = require('../helpers'); -var runMochaJSON = helpers.runMochaJSON; -var resolvePath = helpers.resolveFixturePath; +const { + runMochaJSON, + resolveFixturePath: resolvePath, + runMocha +} = require('../helpers'); describe('--file', function () { var args = []; @@ -64,4 +66,82 @@ describe('--file', function () { done(); }); }); + + it('should run esm tests passed via file', function (done) { + const esmFile = 'collect-files.fixture.mjs'; + const testArgs = ['--file', resolvePath(esmFile)]; + + runMochaJSON(esmFile, testArgs, function (err, res) { + if (err) { + return done(err); + } + expect(res, 'to have passed'); + done(); + }); + }); + + it('should log a warning if a nonexistent file with an unknown extension is specified', function (done) { + const nonexistentTestFileArg = 'nonexistent.test.ts'; + runMocha( + nonexistentTestFileArg, + ['--file'], + function (err, res) { + if (err) { + return done(err); + } + + expect( + res.output, + 'to contain', + `Warning: Cannot find any files matching pattern` + ).and('to contain', nonexistentTestFileArg); + done(); + }, + {stdio: 'pipe'} + ); + }); + + it('should provide warning for nonexistent js file extensions', function (done) { + const nonexistentCjsArg = 'nonexistent.test.js'; + + runMocha( + nonexistentCjsArg, + ['--file'], + function (err, res) { + if (err) { + return done(err); + } + + expect( + res.output, + 'to contain', + `Warning: Cannot find any files matching pattern` + ).and('to contain', nonexistentCjsArg); + done(); + }, + {stdio: 'pipe'} + ); + }); + + it('should provide warning for nonexistent esm file extensions', function (done) { + const nonexistentEsmArg = 'nonexistent.test.mjs'; + + runMocha( + nonexistentEsmArg, + ['--file'], + function (err, res) { + if (err) { + return done(err); + } + + expect( + res.output, + 'to contain', + `Warning: Cannot find any files matching pattern` + ).and('to contain', nonexistentEsmArg); + done(); + }, + {stdio: 'pipe'} + ); + }); }); From 545b66d5927472378aed8e19317212a7535c1650 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 25 Jun 2024 02:20:25 -0400 Subject: [PATCH 21/34] docs: add 10.5.1 to CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc515e5d3c..34f02204bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 10.5.1 / 2024-05-24 + +### :bug: Fixes + +- [#5086](https://github.com/mochajs/mocha/pull/5086) fix: Add error handling for nonexistent file case with --file option ([**@khoaHyh**](https://github.com/khoaHyh)) + ## 10.5.0 / 2024-05-24 ### :tada: Enhancements From 103c56b63542e36ba7a289ec25913d77bf2156b6 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 25 Jun 2024 02:20:54 -0400 Subject: [PATCH 22/34] Release v10.5.1 --- AUTHORS | 1 + package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index a872e5c109..0f46f00d64 100644 --- a/AUTHORS +++ b/AUTHORS @@ -559,5 +559,6 @@ StevenMia <166844090+StevenMia@users.noreply.github.com> Simon Hanna <33220646+simhnna@users.noreply.github.com> Ilia Choly Marjorie Saito +Khoa Huynh <58313491+khoaHyh@users.noreply.github.com> # Generated by scripts/update-authors.js diff --git a/package-lock.json b/package-lock.json index d9e2b95f89..f55017bbdb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mocha", - "version": "10.5.0", + "version": "10.5.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mocha", - "version": "10.5.0", + "version": "10.5.1", "license": "MIT", "dependencies": { "ansi-colors": "4.1.1", diff --git a/package.json b/package.json index 04adfa1d54..13d879c73d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mocha", - "version": "10.5.0", + "version": "10.5.1", "type": "commonjs", "description": "simple, flexible, fun test framework", "keywords": [ From 02c04c48d751554532ceeeb59786b457847cd4f3 Mon Sep 17 00:00:00 2001 From: Sam Adams <107990625+sam-super@users.noreply.github.com> Date: Wed, 26 Jun 2024 18:51:55 +0100 Subject: [PATCH 23/34] fix: better tracking of seen objects in error serialization (#5032) * fix: closes #4552 Breaks circular references in before objects are serialized to prevent cryptic error in parallel mode. * chore: trigger test re-run --- lib/nodejs/serializer.js | 16 ++++----- lib/utils.js | 33 +++++++++++++++++++ .../fixtures/parallel/circular-error.mjs | 10 ++++++ test/integration/parallel.spec.js | 13 ++++++++ 4 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 test/integration/fixtures/parallel/circular-error.mjs diff --git a/lib/nodejs/serializer.js b/lib/nodejs/serializer.js index cfdd3a69fd..25d2e39727 100644 --- a/lib/nodejs/serializer.js +++ b/lib/nodejs/serializer.js @@ -6,7 +6,7 @@ 'use strict'; -const {type} = require('../utils'); +const {type, breakCircularDeps} = require('../utils'); const {createInvalidArgumentTypeError} = require('../errors'); // this is not named `mocha:parallel:serializer` because it's noisy and it's // helpful to be able to write `DEBUG=mocha:parallel*` and get everything else. @@ -188,14 +188,9 @@ class SerializableEvent { * @param {Array} pairs - List of parent/key tuples to process; modified in-place. This JSDoc type is an approximation * @param {object} parent - Some parent object * @param {string} key - Key to inspect - * @param {WeakSet} seenObjects - For avoiding circular references */ - static _serialize(pairs, parent, key, seenObjects) { + static _serialize(pairs, parent, key) { let value = parent[key]; - if (seenObjects.has(value)) { - parent[key] = Object.create(null); - return; - } let _type = type(value); if (_type === 'error') { // we need to reference the stack prop b/c it's lazily-loaded. @@ -263,13 +258,14 @@ class SerializableEvent { error: this.originalError }); + // mutates the object + breakCircularDeps(result); + const pairs = Object.keys(result).map(key => [result, key]); - const seenObjects = new WeakSet(); let pair; while ((pair = pairs.shift())) { - SerializableEvent._serialize(pairs, ...pair, seenObjects); - seenObjects.add(pair[0]); + SerializableEvent._serialize(pairs, ...pair); } this.data = result.data; diff --git a/lib/utils.js b/lib/utils.js index fc7271d019..4de9d28276 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -647,3 +647,36 @@ exports.assignNewMochaID = obj => { */ exports.getMochaID = obj => obj && typeof obj === 'object' ? obj[MOCHA_ID_PROP_NAME] : undefined; + +/** + * Replaces any detected circular dependency with the string '[Circular]' + * Mutates original object + * @param inputObj {*} + * @returns {*} + */ +exports.breakCircularDeps = inputObj => { + const seen = new Set(); + + function _breakCircularDeps(obj) { + if (obj && typeof obj !== 'object') { + return obj; + } + + if (seen.has(obj)) { + return '[Circular]'; + } + + seen.add(obj); + for (const k in obj) { + if (Object.prototype.hasOwnProperty.call(obj, k)) { + obj[k] = _breakCircularDeps(obj[k], k); + } + } + + // deleting means only a seen object that is its own child will be detected + seen.delete(obj); + return obj; + } + + return _breakCircularDeps(inputObj); +}; diff --git a/test/integration/fixtures/parallel/circular-error.mjs b/test/integration/fixtures/parallel/circular-error.mjs new file mode 100644 index 0000000000..5e3787b83f --- /dev/null +++ b/test/integration/fixtures/parallel/circular-error.mjs @@ -0,0 +1,10 @@ +import {describe,it} from "../../../../index.js"; + +describe('test1', () => { + it('test', () => { + const error = new Error('Foo'); + error.foo = { props: [] }; + error.foo.props.push(error.foo); + throw error; + }); +}); diff --git a/test/integration/parallel.spec.js b/test/integration/parallel.spec.js index 3cdecfcf18..5dc1d07fcd 100644 --- a/test/integration/parallel.spec.js +++ b/test/integration/parallel.spec.js @@ -30,4 +30,17 @@ describe('parallel run', () => { assert.strictEqual(result.stats.failures, 0); assert.strictEqual(result.stats.passes, 3); }); + + it('should correctly handle circular references in an exception', async () => { + const result = await runMochaJSONAsync('parallel/circular-error.mjs', [ + '--parallel', + '--jobs', + '2', + require.resolve('./fixtures/parallel/testworkerid1.mjs') + ]); + assert.strictEqual(result.stats.failures, 1); + assert.strictEqual(result.stats.passes, 1); + assert.strictEqual(result.failures[0].err.message, 'Foo'); + assert.strictEqual(result.failures[0].err.foo.props[0], '[Circular]'); + }); }); From a3bb86d52b96ab9776bb6897337435443ef846cc Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 26 Jun 2024 13:54:06 -0400 Subject: [PATCH 24/34] docs: add 10.5.2 to CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34f02204bb..c4d2663dec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 10.5.2 / 2024-05-25 + +### :bug: Fixes + +- [#5032](https://github.com/mochajs/mocha/pull/5032) fix: better tracking of seen objects in error serialization ([**@sam-super**](https://github.com/sam-super)) + ## 10.5.1 / 2024-05-24 ### :bug: Fixes From b2a6358f860dae732cfcbe5ed86693eadb199fac Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 26 Jun 2024 13:54:27 -0400 Subject: [PATCH 25/34] Release 10.5.2 --- AUTHORS | 1 + package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index 0f46f00d64..96ef9e7a5d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -560,5 +560,6 @@ Simon Hanna <33220646+simhnna@users.noreply.github.com> Ilia Choly Marjorie Saito Khoa Huynh <58313491+khoaHyh@users.noreply.github.com> +Sam Adams <107990625+sam-super@users.noreply.github.com> # Generated by scripts/update-authors.js diff --git a/package-lock.json b/package-lock.json index f55017bbdb..9f3def6edc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mocha", - "version": "10.5.1", + "version": "10.5.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mocha", - "version": "10.5.1", + "version": "10.5.2", "license": "MIT", "dependencies": { "ansi-colors": "4.1.1", diff --git a/package.json b/package.json index 13d879c73d..0d0203e61c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mocha", - "version": "10.5.1", + "version": "10.5.2", "type": "commonjs", "description": "simple, flexible, fun test framework", "keywords": [ From 38695dadba21a488d7c54424a75d537f52cd250a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Tue, 2 Jul 2024 11:46:03 -0400 Subject: [PATCH 26/34] feat: allow ^ versions for character encoding packages (#5150) * feat: allow ^ versions for character encoding packages * escape-string-regexp too * npm install ansi-colors@^4.1.3 * ...but keep package.json's dependencies entry the same * Updated to the latest ansi-colors per review --- package-lock.json | 24 ++++++++++++------------ package.json | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9f3def6edc..dcfc40887f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,22 +9,22 @@ "version": "10.5.2", "license": "MIT", "dependencies": { - "ansi-colors": "4.1.1", - "browser-stdout": "1.3.1", + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", "chokidar": "^3.5.3", "debug": "4.3.4", "diff": "5.0.0", - "escape-string-regexp": "4.0.0", + "escape-string-regexp": "^4.0.0", "find-up": "5.0.0", "glob": "8.1.0", - "he": "1.2.0", + "he": "^1.2.0", "js-yaml": "4.1.0", - "log-symbols": "4.1.0", + "log-symbols": "^4.1.0", "minimatch": "5.0.1", "ms": "2.1.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", - "supports-color": "8.1.1", + "supports-color": "^8.1.1", "workerpool": "6.2.1", "yargs": "16.2.0", "yargs-parser": "20.2.4", @@ -2212,9 +2212,9 @@ } }, "node_modules/ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "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" } @@ -23984,9 +23984,9 @@ } }, "ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==" + "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-escapes": { "version": "4.3.2", diff --git a/package.json b/package.json index 0d0203e61c..f51d624734 100644 --- a/package.json +++ b/package.json @@ -51,22 +51,22 @@ "test:smoke": "node ./bin/mocha --no-config test/smoke/smoke.spec.js" }, "dependencies": { - "ansi-colors": "4.1.1", - "browser-stdout": "1.3.1", + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", "chokidar": "^3.5.3", "debug": "4.3.4", "diff": "5.0.0", - "escape-string-regexp": "4.0.0", + "escape-string-regexp": "^4.0.0", "find-up": "5.0.0", "glob": "8.1.0", - "he": "1.2.0", + "he": "^1.2.0", "js-yaml": "4.1.0", - "log-symbols": "4.1.0", + "log-symbols": "^4.1.0", "minimatch": "5.0.1", "ms": "2.1.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", - "supports-color": "8.1.1", + "supports-color": "^8.1.1", "workerpool": "6.2.1", "yargs": "16.2.0", "yargs-parser": "20.2.4", From 71e9fbae3bd7b706c142cce5b249e65a7c2ce6d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Tue, 2 Jul 2024 11:46:47 -0400 Subject: [PATCH 27/34] feat: allow ^ versions for yargs packages (#5152) * fet: allow ^ versions for yargs packages * Use latest yargs-parser --- package-lock.json | 18 +++++++++--------- package.json | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index dcfc40887f..cdc5fb2be9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,9 +26,9 @@ "strip-json-comments": "3.1.1", "supports-color": "^8.1.1", "workerpool": "6.2.1", - "yargs": "16.2.0", - "yargs-parser": "20.2.4", - "yargs-unparser": "2.0.0" + "yargs": "^16.2.0", + "yargs-parser": "^20.2.9", + "yargs-unparser": "^2.0.0" }, "bin": { "_mocha": "bin/_mocha", @@ -22154,9 +22154,9 @@ } }, "node_modules/yargs-parser": { - "version": "20.2.4", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", - "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", "engines": { "node": ">=10" } @@ -39548,9 +39548,9 @@ } }, "yargs-parser": { - "version": "20.2.4", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", - "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==" + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==" }, "yargs-unparser": { "version": "2.0.0", diff --git a/package.json b/package.json index f51d624734..7a603f643a 100644 --- a/package.json +++ b/package.json @@ -68,9 +68,9 @@ "strip-json-comments": "3.1.1", "supports-color": "^8.1.1", "workerpool": "6.2.1", - "yargs": "16.2.0", - "yargs-parser": "20.2.4", - "yargs-unparser": "2.0.0" + "yargs": "^16.2.0", + "yargs-parser": "^20.2.9", + "yargs-unparser": "^2.0.0" }, "devDependencies": { "@11ty/eleventy": "^1.0.0", From be826062f21ac38e310d981490110c38abacc3f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Tue, 2 Jul 2024 11:52:37 -0400 Subject: [PATCH 28/34] feat: allow ^ versions for file matching packages (#5151) * feat: allow ^ versions for character encoding packages * Use latest minimatch --- package-lock.json | 41 +++++++++-------------------------------- package.json | 6 +++--- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/package-lock.json b/package-lock.json index cdc5fb2be9..8732fb5395 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,12 +15,12 @@ "debug": "4.3.4", "diff": "5.0.0", "escape-string-regexp": "^4.0.0", - "find-up": "5.0.0", - "glob": "8.1.0", + "find-up": "^5.0.0", + "glob": "^8.1.0", "he": "^1.2.0", "js-yaml": "4.1.0", "log-symbols": "^4.1.0", - "minimatch": "5.0.1", + "minimatch": "^5.1.6", "ms": "2.1.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", @@ -13265,9 +13265,9 @@ "dev": true }, "node_modules/minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -16915,18 +16915,6 @@ "minimatch": "^5.1.0" } }, - "node_modules/readdir-glob/node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", @@ -32606,9 +32594,9 @@ "dev": true }, "minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", "requires": { "brace-expansion": "^2.0.1" } @@ -35415,17 +35403,6 @@ "dev": true, "requires": { "minimatch": "^5.1.0" - }, - "dependencies": { - "minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "dev": true, - "requires": { - "brace-expansion": "^2.0.1" - } - } } }, "readdirp": { diff --git a/package.json b/package.json index 7a603f643a..37f596880b 100644 --- a/package.json +++ b/package.json @@ -57,12 +57,12 @@ "debug": "4.3.4", "diff": "5.0.0", "escape-string-regexp": "^4.0.0", - "find-up": "5.0.0", - "glob": "8.1.0", + "find-up": "^5.0.0", + "glob": "^8.1.0", "he": "^1.2.0", "js-yaml": "4.1.0", "log-symbols": "^4.1.0", - "minimatch": "5.0.1", + "minimatch": "^5.1.6", "ms": "2.1.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", From 514b83ff9b7048130faaff3479882fa0819830e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Tue, 2 Jul 2024 12:00:40 -0400 Subject: [PATCH 29/34] feat: allow ^ versions for data serialization packages (#5153) * feat: allow ^ versions for data serialization packages * Use latest serialize-javascript --- package-lock.json | 36 +++++++++--------------------------- package.json | 6 +++--- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8732fb5395..66bff374c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,12 +18,12 @@ "find-up": "^5.0.0", "glob": "^8.1.0", "he": "^1.2.0", - "js-yaml": "4.1.0", + "js-yaml": "^4.1.0", "log-symbols": "^4.1.0", "minimatch": "^5.1.6", "ms": "2.1.3", - "serialize-javascript": "6.0.0", - "strip-json-comments": "3.1.1", + "serialize-javascript": "^6.0.2", + "strip-json-comments": "^3.1.1", "supports-color": "^8.1.1", "workerpool": "6.2.1", "yargs": "^16.2.0", @@ -18433,9 +18433,9 @@ } }, "node_modules/serialize-javascript": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", - "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", "dependencies": { "randombytes": "^2.1.0" } @@ -19979,15 +19979,6 @@ } } }, - "node_modules/terser-webpack-plugin/node_modules/serialize-javascript": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.1.tgz", - "integrity": "sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==", - "dev": true, - "dependencies": { - "randombytes": "^2.1.0" - } - }, "node_modules/terser-webpack-plugin/node_modules/terser": { "version": "5.16.6", "resolved": "https://registry.npmjs.org/terser/-/terser-5.16.6.tgz", @@ -36600,9 +36591,9 @@ } }, "serialize-javascript": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", - "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", "requires": { "randombytes": "^2.1.0" } @@ -37809,15 +37800,6 @@ "terser": "^5.16.5" }, "dependencies": { - "serialize-javascript": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.1.tgz", - "integrity": "sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==", - "dev": true, - "requires": { - "randombytes": "^2.1.0" - } - }, "terser": { "version": "5.16.6", "resolved": "https://registry.npmjs.org/terser/-/terser-5.16.6.tgz", diff --git a/package.json b/package.json index 37f596880b..06cf7e98ef 100644 --- a/package.json +++ b/package.json @@ -60,12 +60,12 @@ "find-up": "^5.0.0", "glob": "^8.1.0", "he": "^1.2.0", - "js-yaml": "4.1.0", + "js-yaml": "^4.1.0", "log-symbols": "^4.1.0", "minimatch": "^5.1.6", "ms": "2.1.3", - "serialize-javascript": "6.0.0", - "strip-json-comments": "3.1.1", + "serialize-javascript": "^6.0.2", + "strip-json-comments": "^3.1.1", "supports-color": "^8.1.1", "workerpool": "6.2.1", "yargs": "^16.2.0", From bb8d7b954495b33f93010ee43f39b9ab5ec37308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Tue, 2 Jul 2024 12:03:39 -0400 Subject: [PATCH 30/34] feat: allow ^ versions for miscellaneous packages (#5154) * feat: allow ^ versions for miscellaneous packages * Use latest for several --- package-lock.json | 82 ++++++++++++++++++++++++++++++++++------------- package.json | 8 ++--- 2 files changed, 64 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index 66bff374c4..e925516aec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,8 +12,8 @@ "ansi-colors": "^4.1.3", "browser-stdout": "^1.3.1", "chokidar": "^3.5.3", - "debug": "4.3.4", - "diff": "5.0.0", + "debug": "^4.3.5", + "diff": "^5.2.0", "escape-string-regexp": "^4.0.0", "find-up": "^5.0.0", "glob": "^8.1.0", @@ -21,11 +21,11 @@ "js-yaml": "^4.1.0", "log-symbols": "^4.1.0", "minimatch": "^5.1.6", - "ms": "2.1.3", + "ms": "^2.1.3", "serialize-javascript": "^6.0.2", "strip-json-comments": "^3.1.1", "supports-color": "^8.1.1", - "workerpool": "6.2.1", + "workerpool": "^6.5.1", "yargs": "^16.2.0", "yargs-parser": "^20.2.9", "yargs-unparser": "^2.0.0" @@ -5823,9 +5823,9 @@ } }, "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", "dependencies": { "ms": "2.1.2" }, @@ -6490,9 +6490,9 @@ } }, "node_modules/diff": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", "engines": { "node": ">=0.3.1" } @@ -16486,6 +16486,23 @@ "node": ">=10.18.1" } }, + "node_modules/puppeteer-core/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, "node_modules/puppeteer-core/node_modules/devtools-protocol": { "version": "0.0.981744", "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.981744.tgz", @@ -16517,6 +16534,12 @@ "node": ">=8" } }, + "node_modules/puppeteer-core/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, "node_modules/puppeteer-core/node_modules/p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", @@ -21983,9 +22006,9 @@ } }, "node_modules/workerpool": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", - "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==" + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==" }, "node_modules/wrap-ansi": { "version": "7.0.0", @@ -26906,9 +26929,9 @@ "dev": true }, "debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", "requires": { "ms": "2.1.2" }, @@ -27402,9 +27425,9 @@ "dev": true }, "diff": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==" + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==" }, "diffie-hellman": { "version": "5.0.3", @@ -35075,6 +35098,15 @@ "ws": "8.5.0" }, "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, "devtools-protocol": { "version": "0.0.981744", "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.981744.tgz", @@ -35100,6 +35132,12 @@ "p-locate": "^4.1.0" } }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, "p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", @@ -39395,9 +39433,9 @@ } }, "workerpool": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", - "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==" + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==" }, "wrap-ansi": { "version": "7.0.0", diff --git a/package.json b/package.json index 06cf7e98ef..cdbc8fac73 100644 --- a/package.json +++ b/package.json @@ -54,8 +54,8 @@ "ansi-colors": "^4.1.3", "browser-stdout": "^1.3.1", "chokidar": "^3.5.3", - "debug": "4.3.4", - "diff": "5.0.0", + "debug": "^4.3.5", + "diff": "^5.2.0", "escape-string-regexp": "^4.0.0", "find-up": "^5.0.0", "glob": "^8.1.0", @@ -63,11 +63,11 @@ "js-yaml": "^4.1.0", "log-symbols": "^4.1.0", "minimatch": "^5.1.6", - "ms": "2.1.3", + "ms": "^2.1.3", "serialize-javascript": "^6.0.2", "strip-json-comments": "^3.1.1", "supports-color": "^8.1.1", - "workerpool": "6.2.1", + "workerpool": "^6.5.1", "yargs": "^16.2.0", "yargs-parser": "^20.2.9", "yargs-unparser": "^2.0.0" From 528836eae9855d30c28bcf9f36577b4f1f34a7c9 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 2 Jul 2024 12:08:24 -0400 Subject: [PATCH 31/34] docs: fix month numbers in CHANGELOG.md --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4d2663dec..afb13a5ecb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,18 +1,18 @@ # Changelog -## 10.5.2 / 2024-05-25 +## 10.5.2 / 2024-06-25 ### :bug: Fixes - [#5032](https://github.com/mochajs/mocha/pull/5032) fix: better tracking of seen objects in error serialization ([**@sam-super**](https://github.com/sam-super)) -## 10.5.1 / 2024-05-24 +## 10.5.1 / 2024-06-24 ### :bug: Fixes - [#5086](https://github.com/mochajs/mocha/pull/5086) fix: Add error handling for nonexistent file case with --file option ([**@khoaHyh**](https://github.com/khoaHyh)) -## 10.5.0 / 2024-05-24 +## 10.5.0 / 2024-06-24 ### :tada: Enhancements From 021aa80442436b448c4b1da81449676928610be7 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 2 Jul 2024 12:12:19 -0400 Subject: [PATCH 32/34] docs: add 10.6.0 to CHANGELOG.md --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index afb13a5ecb..696955c68c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 10.6.0 / 2024-07-02 + +### :tada: Enhancements + +- [#5150](https://github.com/mochajs/mocha/pull/5150) feat: allow ^ versions for character encoding packages ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) +- [#5151](https://github.com/mochajs/mocha/pull/5151) feat: allow ^ versions for file matching packages ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) +- [#5152](https://github.com/mochajs/mocha/pull/5152) feat: allow ^ versions for yargs packages ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) +- [#5153](https://github.com/mochajs/mocha/pull/5153) feat: allow ^ versions for data serialization packages ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) +- [#5154](https://github.com/mochajs/mocha/pull/5154) feat: allow ^ versions for miscellaneous packages ([**@JoshuaKGoldberg**](https://github.com/JoshuaKGoldberg)) + ## 10.5.2 / 2024-06-25 ### :bug: Fixes From 177732fee8b73be23bf7e1d4fbb851b13d36f6bf Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 2 Jul 2024 12:12:50 -0400 Subject: [PATCH 33/34] Release 10.6.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e925516aec..cae914546d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mocha", - "version": "10.5.2", + "version": "10.6.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mocha", - "version": "10.5.2", + "version": "10.6.0", "license": "MIT", "dependencies": { "ansi-colors": "^4.1.3", diff --git a/package.json b/package.json index cdbc8fac73..1aef27db88 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mocha", - "version": "10.5.2", + "version": "10.6.0", "type": "commonjs", "description": "simple, flexible, fun test framework", "keywords": [ From c43930cc6dc41980f4fcf054d506d780a28a72df Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Wed, 3 Jul 2024 03:03:50 +1000 Subject: [PATCH 34/34] docs: Add warning about async callback for describe (#5046) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs: Add warning about async callback for describe I couldn't find any reference to `describe` not supporting an async function. It seems like a natural idea given `it` and `before` do. I spent considerable time trying to figure out why an async test was failing before I discovered the reason deep in an issue discussion (https://github.com/mochajs/mocha/issues/2975#issuecomment-1004176440), so hope that this helps others design their test suites! * Update docs/index.md Co-authored-by: Josh Goldberg ✨ * Update docs/index.md Co-authored-by: Josh Goldberg ✨ --------- Co-authored-by: Josh Goldberg ✨ --- docs/index.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/index.md b/docs/index.md index bf9c12fd23..cc3d9eb2ab 100644 --- a/docs/index.md +++ b/docs/index.md @@ -298,6 +298,11 @@ describe('#find()', function () { }); ``` +### Limitations of asynchronous callbacks + +You can use all asynchronous callbacks (`done`, `Promise`, and `async`/`await`) in callbacks for `it()`, `before()`, `after()`, `beforeEach()`, `afterEach()`) but not `describe()` -- it must be synchronous. +See [#5046](https://github.com/mochajs/mocha/pull/5046) for more information. + ## Synchronous Code When testing synchronous code, omit the callback and Mocha will automatically continue on to the next test.