☕️ Classic, reliable, trusted test framework for Node.js and the browser
chore: add folder for reproducing issues (#6330)
Mark Wiemer672803069c1f
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.mdindex 51bf2227..8baf1517 100644--- a/.github/CONTRIBUTING.md+++ b/.github/CONTRIBUTING.md@@ -19,19 +19,17 @@ This includes bugs, feature requests, and improvements to documentation.Sorry!It happens to the best of us.-Please [file an issue using the bug report template](https://github.com/mochajs/mocha/issues/new?assignees=&labels=type%3A+bug&projects=&template=01-bug.yml&title=%F0%9F%90%9B+Bug%3A+%3Cshort+description+of+the+bug%3E) with _as much detail as possible_ to help us reproduce and diagnose the bug.-Most importantly:+First, please confirm the bug by reproducing it in a minimal project.+You can use the [repro folder](../repro/README.md) for this,+or you can describe the minimal reproduction in the bug description.-- Let us know _how_ you're running Mocha (options, flags, environment, browser or Node.js, etc.).-- Include your test code or file(s).- If large, please provide a link to a repository or [gist](https://gist.github.com).+Then, [file an issue using the bug report template](https://github.com/mochajs/mocha/issues/new?template=01-bug.yml).If we need more information from you, we'll let you know.-If you don't within a few weeks, your issue will be closed for inactivity.### ❗️ Propose a Change-Please [file an issue using the feature request template](https://github.com/mochajs/mocha/issues/new?assignees=&labels=type%3A+feature&projects=&template=03-feature-request.yml&title=%F0%9F%9A%80+Feature%3A+%3Cshort+description+of+the+feature%3E).+Please [file an issue using the feature request template](https://github.com/mochajs/mocha/issues/new?assignees=&labels=type%3A+feature&projects=&template=03-feature-request.yml).Most importantly:- Let us know _what_ the proposed change is, in as much detail as you candiff --git a/.nycrc b/.nycrcindex f0779c11..29ed39ef 100644--- a/.nycrc+++ b/.nycrc@@ -5,6 +5,7 @@"coverage/**","docs/**","packages/*/test{,s}/**",+ "repro/**","**/*.d.ts","test{,s}/**","test{,-*}.{js,cjs,mjs,ts}",@@ -14,7 +15,6 @@"**/playwright.config.js","**/{babel.config,.eslintrc,.mocharc}.{js,cjs}","lib/browser/**",- "package-scripts.js","package-lock.json","**/package-lock.json","node_modules/**",diff --git a/repro/.gitignore b/repro/.gitignorenew file mode 100644index 00000000..3c3629e6--- /dev/null+++ b/repro/.gitignore@@ -0,0 +1 @@+node_modulesdiff --git a/repro/.mocharc.yml b/repro/.mocharc.ymlnew file mode 100644index 00000000..0967ef42--- /dev/null+++ b/repro/.mocharc.yml@@ -0,0 +1 @@+{}diff --git a/repro/README.md b/repro/README.mdnew file mode 100644index 00000000..dfd8ad5f--- /dev/null+++ b/repro/README.md@@ -0,0 +1,146 @@+# Mocha repros++This folder is completely separate from the Mocha project+so that you can test Mocha behavior in-repo+but in a way similar to an end-user.++Using this folder is completely optional.+If you prefer your own Git repo or some other method, go ahead!++## Usage++### Getting started++This is a minimal Node project.+`cd` to this directory, run `npm i`, then run `npm test` to make sure things work as expected.+Below is sample output; your versions of Mocha and Node may be different,+but the exit code should be 0.++```log+$ npm test++> test+> mocha; echo Exit code $?; echo Mocha $(mocha --version); echo Node $(node --version)++++ ✔ works++ 1 passing (1ms)++Exit code 0+Mocha 12.0.1+Node v22.21.1+```++### Reproducing an issue++You can modify `package.json`, `test/hello.spec.js`,+and any other file in this folder to make this project into a bug reproduction.+You can add new files if needed!+Maintainers appreciate comprehensive console logs like the one seen above+pasted as plain text for easy copy-pasting.++You can modify this README.md with bug details and repro logs here,+or you can create a new `repro.md` if you prefer.++If you need any support, feel free to [reach out on Discord](https://discord.gg/KeDn2uXhER) or [create an issue](https://github.com/mochajs/mocha/issues/new/choose).++Below you'll find more details about this folder.++#### Repro logs++(This space intentionally left blank--feel free to put your logs here!)++### Debug logs++For debug logs, use `npm run test:debug`.+Below are sample abbreviated logs.+Mocha uses [the `debug` project](https://npmx.dev/package/debug) for these logs.++```log+$ npm run test:debug++> test:debug+> npx cross-env DEBUG=mocha:* npm test+++> test+> mocha; echo Exit code $?; echo Mocha $(mocha --version); echo Node $(node --version)++ mocha:esm-utils assigning requireOrImport, require_module === true +0ms+ mocha:cli:parse-args starting splitArgs() +0ms+ mocha:cli:parse-args splitArgs took in array, returning argument unchanged +0ms+ mocha:cli:parse-args starting splitArgs() +1ms+ mocha:cli:parse-args splitArgs took in falsy value, returning empty array +0ms+ mocha:cli:config findConfig: found config file /.../mocha/repro/.mocharc.yml +0ms+ mocha:cli:config loadConfig: trying to parse config at /.../mocha/repro/.mocharc.yml +0ms++ ...++ mocha:runner _addEventListener(): adding for event unhandledRejection; 0 current listeners +0ms+ mocha:runner run(): starting +0ms+ mocha:runner run(): emitting start +0ms++ mocha:runner run(): emitted start +1ms+ mocha:runner runSuite(): running +0ms++ mocha:runner _addEventListener(): adding for event error; 0 current listeners +0ms+ ✔ works+ mocha:runner run(): root suite completed; emitting end +0ms++ 1 passing (1ms)++ mocha:runner run(): emitted end +0ms+Exit code 0+ mocha:esm-utils assigning requireOrImport, require_module === true +0ms+ mocha:cli:parse-args starting splitArgs(--version) +0ms+ mocha:cli:parse-args splitArgs took in array, returning argument unchanged +0ms+ mocha:cli:mocha loaded opts { _: [], version: true } +0ms+ mocha:cli:mocha running Mocha in-process +0ms+ mocha:cli:cli entered main with raw args [] +0ms+Mocha 12.0.1+Node v22.21.1+```++#### Filtering debug logs++You can modify the `test:debug` script in `package.json` to filter the debug logs.++```diff+-"test:debug": "npx cross-env DEBUG=mocha:* npm test",++"test:debug": "npx cross-env DEBUG=mocha:cli:run:helpers npm test",+```++```log+$ npm run test:debug++> test:debug+> npx cross-env DEBUG=mocha:cli:run:helpers npm test+++> test+> mocha; echo Exit code $?; echo Mocha $(mocha --version); echo Node $(node --version)++ mocha:cli:run:helpers test files (in order): [+ '/.../mocha/repro/test/hello.spec.js'+] +0ms+ mocha:cli:run:helpers single run with 1 file(s) +0ms+++ ✔ works++ 1 passing (1ms)++Exit code 0+Mocha 12.0.1+Node v22.21.1+```++### package.json++This is a normal package.json.+The `//` prop is just for humans, and the props inside are sample values.+`file:..` is how to use this exact checkout of Mocha for testing.+Otherwise, `12.0.1` and `11.8.0` are sample values of supported Mocha releases.+If they're outdated, feel free to update them!diff --git a/repro/package-lock.json b/repro/package-lock.jsonnew file mode 100644index 00000000..f17db7c3--- /dev/null+++ b/repro/package-lock.json@@ -0,0 +1,181 @@+{+ "name": "repros",+ "lockfileVersion": 3,+ "requires": true,+ "packages": {+ "": {+ "devDependencies": {+ "cross-env": "10.1.0",+ "mocha": "file:.."+ }+ },+ "..": {+ "version": "12.0.1",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "browser-stdout": "^1.3.1",+ "chokidar": "^5.0.0",+ "debug": "^4.3.5",+ "diff": "^9.0.0",+ "find-up": "^8.0.0",+ "glob": "^13.0.0",+ "is-path-inside": "^4.0.0",+ "is-unicode-supported": "^0.1.0",+ "js-yaml": "^5.0.0",+ "minimatch": "^10.2.2",+ "ms": "^2.1.3",+ "picocolors": "^1.1.1",+ "serialize-javascript": "^7.1.1",+ "strip-json-comments": "^5.0.3",+ "supports-color": "^8.1.1",+ "workerpool": "^10.0.0"+ },+ "bin": {+ "mocha": "bin/mocha.js"+ },+ "devDependencies": {+ "@eslint/js": "^10.0.0",+ "@eslint/markdown": "^8.0.0",+ "@playwright/test": "^1.60.0",+ "@rollup/plugin-alias": "^6.0.0",+ "@rollup/plugin-commonjs": "^29.0.0",+ "@rollup/plugin-json": "^6.1.0",+ "@rollup/plugin-node-resolve": "^16.0.3",+ "@test/esm-only-loader": "./test/compiler-fixtures/esm-only-loader",+ "@types/node": "^24.0.0",+ "chai": "^6.0.0",+ "coffeescript": "^2.6.1",+ "cross-env": "^10.0.0",+ "eslint": "^10.0.0",+ "eslint-plugin-n": "^18.0.0",+ "globals": "^17.0.0",+ "installed-check": "^10.0.0",+ "knip": "^6.0.0",+ "npm-run-all2": "^8.0.0",+ "nyc": "^18.0.0",+ "prettier": "3.9.5",+ "ps-list": "^9.0.0",+ "remark": "^15.0.0",+ "remark-github": "^12.0.0",+ "remark-inline-links": "^7.0.0",+ "rewiremock": "^3.14.3",+ "rimraf": "^6.0.0",+ "rollup": "^4.52.3",+ "rollup-plugin-polyfill-node": "^0.13.0",+ "rollup-plugin-visualizer": "^6.0.5",+ "semver": "^7.7.2",+ "sinon": "^22.0.0",+ "typescript": "^5.8.3",+ "unexpected": "^13.2.1",+ "unexpected-eventemitter": "^2.4.0",+ "unexpected-sinon": "^11.1.0",+ "webpack": "^5.67.0",+ "webpack-cli": "^7.0.2"+ },+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@epic-web/invariant": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/@epic-web/invariant/-/invariant-1.0.0.tgz",+ "integrity": "sha512-lrTPqgvfFQtR/eY/qkIzp98OGdNJu0m5ji3q/nJI8v3SXkRKEnWiOxMmbvcSoAIzv/cGiuvRy57k4suKQSAdwA==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/cross-env": {+ "version": "10.1.0",+ "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-10.1.0.tgz",+ "integrity": "sha512-GsYosgnACZTADcmEyJctkJIoqAhHjttw7RsFrVoJNXbsWWqaq6Ym+7kZjq6mS45O0jij6vtiReppKQEtqWy6Dw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@epic-web/invariant": "^1.0.0",+ "cross-spawn": "^7.0.6"+ },+ "bin": {+ "cross-env": "dist/bin/cross-env.js",+ "cross-env-shell": "dist/bin/cross-env-shell.js"+ },+ "engines": {+ "node": ">=20"+ }+ },+ "node_modules/cross-spawn": {+ "version": "7.0.6",+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",+ "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "path-key": "^3.1.0",+ "shebang-command": "^2.0.0",+ "which": "^2.0.1"+ },+ "engines": {+ "node": ">= 8"+ }+ },+ "node_modules/isexe": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",+ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",+ "dev": true,+ "license": "ISC"+ },+ "node_modules/mocha": {+ "resolved": "..",+ "link": true+ },+ "node_modules/path-key": {+ "version": "3.1.1",+ "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",+ "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/shebang-command": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",+ "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "shebang-regex": "^3.0.0"+ },+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/shebang-regex": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",+ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/which": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",+ "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",+ "dev": true,+ "license": "ISC",+ "dependencies": {+ "isexe": "^2.0.0"+ },+ "bin": {+ "node-which": "bin/node-which"+ },+ "engines": {+ "node": ">= 8"+ }+ }+ }+}diff --git a/repro/package.json b/repro/package.jsonnew file mode 100644index 00000000..3ffd4cd3--- /dev/null+++ b/repro/package.json@@ -0,0 +1,23 @@+{+ "type": "module",+ "//": {+ "1": "See README.md for details on this file",+ "dependencies": {+ "mocha-local": "file:..",+ "mocha-v11": "11.8.0",+ "mocha-v12": "12.0.1"+ },+ "scripts": {+ "test:debug": "npx cross-env DEBUG=mocha:* npm test",+ "test": "mocha; echo Exit code $?; echo Mocha $(mocha --version); echo Node $(node --version)"+ }+ },+ "scripts": {+ "test:debug": "npx cross-env DEBUG=mocha:* npm test",+ "test": "mocha; echo Exit code $?; echo Mocha $(mocha --version); echo Node $(node --version)"+ },+ "devDependencies": {+ "cross-env": "10.1.0",+ "mocha": "file:.."+ }+}diff --git a/repro/test/hello.spec.js b/repro/test/hello.spec.jsnew file mode 100644index 00000000..536e03ee--- /dev/null+++ b/repro/test/hello.spec.js@@ -0,0 +1 @@+it("works", () => {});