Repository: ember-cli/ember-cli (js)

Issue:
How do you run just one test?
The `pnpm test` command has some abstraction which makes using mocha flags directly inaccessible

Pull request:
Make tests easier to run, closes #10520
Closes #10520 

Found that this was needed while I was exploring https://github.com/ember-cli/ember-cli/pull/10516

Can now do:

```bash
pnpm mocha --fgrep "name of test"
```

Examples:

```bash
pnpm mocha --fgrep "Acceptance: ember init"
```
or
```bash
pnpm mocha --fgrep "Acceptance: ember new"
```

Patch:
diff --git a/.mocharc.js b/.mocharc.js
new file mode 100644
index 000000000..3d8b49538
--- /dev/null
+++ b/.mocharc.js
@@ -0,0 +1,17 @@
+'use strict';
+
+const ciInfo = require('ci-info');
+let reporter = process.env.MOCHA_REPORTER || (ciInfo.isCI ? 'tap' : 'spec');
+const chaiJestSnapshot = require('chai-jest-snapshot');
+
+module.exports = {
+  timeout: 5000,
+  reporter,
+  retries: 2,
+  rootHooks: {
+    beforeEach() {
+      chaiJestSnapshot.resetSnapshotRegistry();
+      chaiJestSnapshot.configureUsingMochaContext(this);
+    },
+  },
+};
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index de53f267b..6cb222884 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -37,17 +37,29 @@ for more information.
 ## Run the test suite
 
 ```
-npm test
+pnpm test
 ```
 
 will run ESLint and the "fast" subset of the test suite. Run
-`npm run test:all` for the full test suite which will currently take quite a
+`pnpm run test:all` for the full test suite which will currently take quite a
 few minutes due to heavy IO and network usage.
 
+To run a single test 
+```
+pnpm mocha --fgrep "ember new adds ember-welcome-page by default"
+```
+
+To get help with mocha, run
+```
+pnpm mocha --help
+```
+
 ember-cli is using [Mocha](https://mochajs.org/) for its internal tests. If
 you want to run a specific subset of tests have a look at their
 [documentation](https://mochajs.org/#exclusive-tests).
 
+
+
 ## Update fixtures
 
 ### `ember new`
diff --git a/package.json b/package.json
index b9c100a0d..16e627c21 100644
--- a/package.json
+++ b/package.json
@@ -30,6 +30,7 @@
     "docs": "yuidoc",
     "lint": "eslint . --cache",
     "prepack": "pnpm docs",
+    "mocha": "pnpm exec mocha --require ./tests/bootstrap.js tests/**/*-test.js",
     "test": "node --unhandled-rejections=strict tests/runner",
     "test:all": "node --unhandled-rejections=strict tests/runner all",
     "test:cover": "nyc --all --reporter=text --reporter=lcov node tests/runner all",


Test patch:
diff --git a/tests/bootstrap.js b/tests/bootstrap.js
new file mode 100644
index 000000000..f58f0cf59
--- /dev/null
+++ b/tests/bootstrap.js
@@ -0,0 +1,13 @@
+'use strict';
+
+const chai = require('chai');
+
+const chaiAsPromised = require('chai-as-promised');
+const chaiFiles = require('chai-files');
+const chaiJestSnapshot = require('chai-jest-snapshot');
+
+chai.use(chaiFiles);
+chai.use(chaiAsPromised);
+chai.use(chaiJestSnapshot);
+
+module.exports = { chai };
diff --git a/tests/runner.js b/tests/runner.js
index 1a7c00368..ae5bab479 100644
--- a/tests/runner.js
+++ b/tests/runner.js
@@ -1,35 +1,20 @@
 'use strict';
 
+const path = require('path');
 const captureExit = require('capture-exit');
 captureExit.captureExit();
 
-const chai = require('chai');
-const chaiAsPromised = require('chai-as-promised');
-const chaiFiles = require('chai-files');
-const chaiJestSnapshot = require('chai-jest-snapshot');
-const ciInfo = require('ci-info');
 const glob = require('glob');
 const Mocha = require('mocha');
+const mochaConfig = require(path.join(__dirname, '../.mocharc'));
 
-chai.use(chaiFiles);
-chai.use(chaiAsPromised);
-chai.use(chaiJestSnapshot);
+const { chai } = require('./bootstrap');
+
+const mocha = new Mocha(mochaConfig);
 
 let root = 'tests/{unit,integration,acceptance}';
 let optionOrFile = process.argv[2];
 // default to `tap` reporter in CI otherwise default to `spec`
-let reporter = process.env.MOCHA_REPORTER || (ciInfo.isCI ? 'tap' : 'spec');
-let mocha = new Mocha({
-  timeout: 5000,
-  reporter,
-  retries: 2,
-  rootHooks: {
-    beforeEach() {
-      chaiJestSnapshot.resetSnapshotRegistry();
-      chaiJestSnapshot.configureUsingMochaContext(this);
-    },
-  },
-});
 let testFiles = glob.sync(`${root}/**/*-test.js`);
 let docsLintPosition = testFiles.indexOf('tests/unit/docs-lint-test.js');
 let docsLint = testFiles.splice(docsLintPosition, 1);