mocha 11.2.0 → 11.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cli/cli.js CHANGED
@@ -20,7 +20,7 @@ const {
20
20
  } = require('./options');
21
21
  const lookupFiles = require('./lookup-files');
22
22
  const commands = require('./commands');
23
- const ansi = require('ansi-colors');
23
+ const pc = require('picocolors');
24
24
  const {repository, homepage, version, discord} = require('../../package.json');
25
25
  const {cwd} = require('../utils');
26
26
 
@@ -60,7 +60,7 @@ exports.main = (argv = process.argv.slice(2), mochaArgs) => {
60
60
  .fail((msg, err, yargs) => {
61
61
  debug('caught error sometime before command handler: %O', err);
62
62
  yargs.showHelp();
63
- console.error(`\n${symbols.error} ${ansi.red('ERROR:')} ${msg}`);
63
+ console.error(`\n${symbols.error} ${pc.red('ERROR:')} ${msg}`);
64
64
  process.exit(1);
65
65
  })
66
66
  .help('help', 'Show usage information & exit')
@@ -69,10 +69,10 @@ exports.main = (argv = process.argv.slice(2), mochaArgs) => {
69
69
  .alias('version', 'V')
70
70
  .wrap(process.stdout.columns ? Math.min(process.stdout.columns, 80) : 80)
71
71
  .epilog(
72
- `${ansi.reset("Mocha Resources")}
73
- Chat: ${ansi.magenta(discord)}
74
- GitHub: ${ansi.blue(repository.url)}
75
- Docs: ${ansi.yellow(homepage)}
72
+ `${pc.reset("Mocha Resources")}
73
+ Chat: ${pc.magenta(discord)}
74
+ GitHub: ${pc.blue(repository.url)}
75
+ Docs: ${pc.yellow(homepage)}
76
76
  `
77
77
  )
78
78
  .parserConfiguration(YARGS_PARSER_CONFIG)
@@ -2,7 +2,7 @@
2
2
 
3
3
  const fs = require('node:fs');
4
4
  const path = require('node:path');
5
- const ansi = require('ansi-colors');
5
+ const pc = require('picocolors');
6
6
  const debug = require('debug')('mocha:cli:run:helpers');
7
7
  const minimatch = require('minimatch');
8
8
  const {NO_FILES_MATCH_PATTERN} = require('../errors').constants;
@@ -94,12 +94,12 @@ module.exports = ({
94
94
  unmatchedSpecFiles[0].pattern
95
95
  )}` // stringify to print escaped characters raw
96
96
  : 'Error: No test files found';
97
- console.error(ansi.red(noneFoundMsg));
97
+ console.error(pc.red(noneFoundMsg));
98
98
  process.exit(1);
99
99
  } else {
100
100
  // print messages as a warning
101
101
  unmatchedSpecFiles.forEach(warning => {
102
- console.warn(ansi.yellow(`Warning: ${warning.message}`));
102
+ console.warn(pc.yellow(`Warning: ${warning.message}`));
103
103
  });
104
104
  }
105
105
 
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  const fs = require('node:fs');
11
- const ansi = require('ansi-colors');
11
+ const pc = require('picocolors');
12
12
  const yargsParser = require('yargs-parser');
13
13
  const {
14
14
  types,
@@ -180,7 +180,7 @@ const parse = (args = [], defaultValues = {}, ...configObjects) => {
180
180
  boolean: types.boolean.concat(nodeArgs.map(pair => pair[0]))
181
181
  });
182
182
  if (result.error) {
183
- console.error(ansi.red(`Error: ${result.error.message}`));
183
+ console.error(pc.red(`Error: ${result.error.message}`));
184
184
  process.exit(1);
185
185
  }
186
186
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  const fs = require('node:fs');
11
11
  const path = require('node:path');
12
- const ansi = require('ansi-colors');
12
+ const pc = require('picocolors');
13
13
  const debug = require('debug')('mocha:cli:run:helpers');
14
14
  const {watchRun, watchParallelRun} = require('./watch-run');
15
15
  const collectFiles = require('./collect-files');
@@ -121,7 +121,7 @@ const handleUnmatchedFiles = (mocha, unmatchedFiles) => {
121
121
 
122
122
  unmatchedFiles.forEach(({pattern, absolutePath}) => {
123
123
  console.error(
124
- ansi.yellow(
124
+ pc.yellow(
125
125
  `Warning: Cannot find any files matching pattern "${pattern}" at the absolute path "${absolutePath}"`
126
126
  )
127
127
  );
package/lib/cli/run.js CHANGED
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  const symbols = require('log-symbols');
11
- const ansi = require('ansi-colors');
11
+ const pc = require('picocolors');
12
12
  const Mocha = require('../mocha');
13
13
  const {
14
14
  createUnsupportedError,
@@ -357,7 +357,7 @@ exports.builder = yargs =>
357
357
  Object.assign(argv, plugins);
358
358
  } catch (err) {
359
359
  // this could be a bad --require, bad reporter, ui, etc.
360
- console.error(`\n${symbols.error} ${ansi.red('ERROR:')}`, err);
360
+ console.error(`\n${symbols.error} ${pc.red('ERROR:')}`, err);
361
361
  yargs.exit(1);
362
362
  }
363
363
  })
@@ -6,6 +6,7 @@ const path = require('node:path');
6
6
  const chokidar = require('chokidar');
7
7
  const Context = require('../context');
8
8
  const collectFiles = require('./collect-files');
9
+ const glob = require('glob');
9
10
 
10
11
  /**
11
12
  * Exports the `watchRun` function that runs mocha in "watch" mode.
@@ -136,6 +137,42 @@ exports.watchRun = (mocha, {watchFiles, watchIgnore}, fileCollectParams) => {
136
137
  });
137
138
  };
138
139
 
140
+ class GlobFilesTracker {
141
+ constructor(watchFiles, watchIgnore) {
142
+ this.watchFilesSet = new Set();
143
+ this.watchFiles = watchFiles;
144
+ this.watchIgnore = watchIgnore;
145
+ }
146
+
147
+ regenerate() {
148
+ const watchIgnoreSet = new Set();
149
+ for (const pattern of this.watchIgnore) {
150
+ glob.sync(pattern, { dot: true }).forEach(filePath => watchIgnoreSet.add(filePath));
151
+ }
152
+
153
+ const globOpts = {
154
+ dot: true,
155
+ ignore: {
156
+ childrenIgnored: pathToCheck => watchIgnoreSet.has(pathToCheck.relative())
157
+ }
158
+ };
159
+
160
+ this.watchFilesSet.clear();
161
+ for (const pattern of this.watchFiles) {
162
+ glob.sync(pattern, globOpts).forEach(pathToCheck => {
163
+ if (watchIgnoreSet.has(pathToCheck)) {
164
+ return;
165
+ }
166
+ this.watchFilesSet.add(pathToCheck);
167
+ });
168
+ }
169
+ }
170
+
171
+ has(filePath) {
172
+ return this.watchFilesSet.has(filePath)
173
+ }
174
+ }
175
+
139
176
  /**
140
177
  * Bootstraps a chokidar watcher. Handles keyboard input & signals
141
178
  * @param {Mocha} mocha - Mocha instance
@@ -167,8 +204,10 @@ const createWatcher = (
167
204
  // we handle global fixtures manually
168
205
  mocha.enableGlobalSetup(false).enableGlobalTeardown(false);
169
206
 
170
- const watcher = chokidar.watch(watchFiles, {
171
- ignored: watchIgnore,
207
+ const tracker = new GlobFilesTracker(watchFiles, watchIgnore);
208
+ tracker.regenerate();
209
+
210
+ const watcher = chokidar.watch('.', {
172
211
  ignoreInitial: true
173
212
  });
174
213
 
@@ -184,8 +223,13 @@ const createWatcher = (
184
223
  rerunner.run();
185
224
  });
186
225
 
187
- watcher.on('all', () => {
188
- rerunner.scheduleRun();
226
+ watcher.on('all', (event, filePath) => {
227
+ if (event === 'add') {
228
+ tracker.regenerate();
229
+ }
230
+ if (tracker.has(filePath)) {
231
+ rerunner.scheduleRun();
232
+ }
189
233
  });
190
234
 
191
235
  hideCursor();
package/mocha.js CHANGED
@@ -1,4 +1,4 @@
1
- // mocha@11.2.0 in javascript ES2018
1
+ // mocha@11.2.2 in javascript ES2018
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -19256,7 +19256,7 @@
19256
19256
  };
19257
19257
 
19258
19258
  var name = "mocha";
19259
- var version = "11.2.0";
19259
+ var version = "11.2.2";
19260
19260
  var homepage = "https://mochajs.org/";
19261
19261
  var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
19262
19262
  var require$$17 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mocha",
3
- "version": "11.2.0",
3
+ "version": "11.2.2",
4
4
  "type": "commonjs",
5
5
  "description": "simple, flexible, fun test framework",
6
6
  "keywords": [
@@ -94,9 +94,8 @@
94
94
  "version": "run-p version:* && git add -A ./AUTHORS ./CHANGELOG.md"
95
95
  },
96
96
  "dependencies": {
97
- "ansi-colors": "^4.1.3",
98
97
  "browser-stdout": "^1.3.1",
99
- "chokidar": "^3.5.3",
98
+ "chokidar": "^4.0.1",
100
99
  "debug": "^4.3.5",
101
100
  "diff": "^5.2.0",
102
101
  "escape-string-regexp": "^4.0.0",
@@ -107,6 +106,7 @@
107
106
  "log-symbols": "^4.1.0",
108
107
  "minimatch": "^5.1.6",
109
108
  "ms": "^2.1.3",
109
+ "picocolors": "^1.1.1",
110
110
  "serialize-javascript": "^6.0.2",
111
111
  "strip-json-comments": "^3.1.1",
112
112
  "supports-color": "^8.1.1",