mocha 12.0.0-beta-8 → 12.0.0-beta-10

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
@@ -9,7 +9,6 @@
9
9
  */
10
10
 
11
11
  const debug = require("debug")("mocha:cli:cli");
12
- const symbols = require("log-symbols");
13
12
  const yargs = require("yargs");
14
13
  const path = require("node:path");
15
14
  const {
@@ -27,7 +26,7 @@ const {
27
26
  version,
28
27
  discord,
29
28
  } = require("../../package.json");
30
- const { cwd } = require("../utils");
29
+ const { cwd, logSymbols } = require("../utils");
31
30
 
32
31
  /**
33
32
  * - Accepts an `Array` of arguments
@@ -65,7 +64,7 @@ exports.main = (argv = process.argv.slice(2), mochaArgs) => {
65
64
  .fail((msg, err, yargs) => {
66
65
  debug("caught error sometime before command handler: %O", err);
67
66
  yargs.showHelp();
68
- console.error(`\n${symbols.error} ${pc.red("ERROR:")} ${msg}`);
67
+ console.error(`\n${logSymbols.error} ${pc.red("ERROR:")} ${msg}`);
69
68
  if (!msg) {
70
69
  // Log raw error and stack when an unexpected error is encountered, to
71
70
  // make debugging easier (instead of an inactionable "ERROR: null").
package/lib/cli/run.js CHANGED
@@ -7,7 +7,6 @@
7
7
  * @private
8
8
  */
9
9
 
10
- const symbols = require("log-symbols");
11
10
  const pc = require("picocolors");
12
11
  const Mocha = require("../mocha");
13
12
  const {
@@ -26,7 +25,7 @@ const { ONE_AND_DONES, ONE_AND_DONE_ARGS } = require("./one-and-dones");
26
25
  const debug = require("debug")("mocha:cli:run");
27
26
  const defaults = require("../mocharc.json");
28
27
  const { types, aliases } = require("./run-option-metadata");
29
- const { isCI } = require("../utils");
28
+ const { isCI, logSymbols } = require("../utils");
30
29
 
31
30
  /**
32
31
  * Logical option groups
@@ -359,7 +358,7 @@ exports.builder = (yargs) =>
359
358
  Object.assign(argv, plugins);
360
359
  } catch (err) {
361
360
  // this could be a bad --require, bad reporter, ui, etc.
362
- console.error(`\n${symbols.error} ${pc.red("ERROR:")}`, err);
361
+ console.error(`\n${logSymbols.error} ${pc.red("ERROR:")}`, err);
363
362
  yargs.exit(1);
364
363
  }
365
364
  })
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- const logSymbols = require("log-symbols");
4
3
  const debug = require("debug")("mocha:cli:watch");
5
4
  const path = require("node:path");
6
5
  const chokidar = require("chokidar");
@@ -9,6 +8,7 @@ const isPathInside = require("is-path-inside");
9
8
  const { minimatch } = require("minimatch");
10
9
  const Context = require("../context");
11
10
  const collectFiles = require("./collect-files");
11
+ const { logSymbols } = require("../utils");
12
12
 
13
13
  /**
14
14
  * @typedef {import('chokidar').FSWatcher} FSWatcher
package/lib/context.js CHANGED
@@ -69,7 +69,7 @@ Context.prototype.slow = function (ms) {
69
69
  * Mark a test as skipped.
70
70
  *
71
71
  * @private
72
- * @throws Pending
72
+ * @throws PendingError
73
73
  */
74
74
  Context.prototype.skip = function () {
75
75
  this.runnable().skip();
@@ -22,9 +22,8 @@ const { createMap, constants } = require("../utils");
22
22
  const { MOCHA_ID_PROP_NAME } = constants;
23
23
  const { createFatalError } = require("../errors");
24
24
 
25
- const DEFAULT_WORKER_REPORTER = require.resolve(
26
- "./reporters/parallel-buffered",
27
- );
25
+ const DEFAULT_WORKER_REPORTER =
26
+ require.resolve("./reporters/parallel-buffered");
28
27
 
29
28
  /**
30
29
  * List of options to _not_ serialize for transmission to workers
package/lib/pending.js CHANGED
@@ -4,13 +4,16 @@
4
4
  @module Pending
5
5
  */
6
6
 
7
- module.exports = Pending;
8
-
9
7
  /**
10
- * Initialize a new `Pending` error with the given message.
8
+ * Initialize a new `PendingError` error with the given message.
11
9
  *
12
10
  * @param {string} message
13
11
  */
14
- function Pending(message) {
15
- this.message = message;
12
+ class PendingError extends Error {
13
+ constructor(message) {
14
+ super(message);
15
+ this.name = "PendingError";
16
+ }
16
17
  }
18
+
19
+ module.exports = PendingError;
@@ -17,7 +17,6 @@ var diff = require("diff");
17
17
  var milliseconds = require("ms");
18
18
  var utils = require("../utils");
19
19
  var supportsColor = require("supports-color");
20
- var symbols = require("log-symbols");
21
20
  var constants = require("../runner").constants;
22
21
  var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
23
22
  var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
@@ -101,8 +100,8 @@ exports.colors = {
101
100
  */
102
101
 
103
102
  exports.symbols = {
104
- ok: symbols.success,
105
- err: symbols.error,
103
+ ok: utils.logSymbols.success,
104
+ err: utils.logSymbols.error,
106
105
  dot: ".",
107
106
  comma: ",",
108
107
  bang: "!",
package/lib/runnable.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var EventEmitter = require("node:events").EventEmitter;
4
- var Pending = require("./pending");
4
+ var PendingError = require("./pending");
5
5
  var debug = require("debug")("mocha:runnable");
6
6
  var milliseconds = require("ms");
7
7
  var utils = require("./utils");
@@ -143,7 +143,7 @@ Runnable.prototype.slow = function (ms) {
143
143
  */
144
144
  Runnable.prototype.skip = function () {
145
145
  this.pending = true;
146
- throw new Pending("sync skip; aborting execution");
146
+ throw new PendingError("sync skip; aborting execution");
147
147
  };
148
148
 
149
149
  /**
@@ -331,7 +331,7 @@ Runnable.prototype.run = function (fn) {
331
331
  this.pending = true;
332
332
  done();
333
333
  // halt execution, the uncaught handler will ignore the failure.
334
- throw new Pending("async skip; aborting execution");
334
+ throw new PendingError("async skip; aborting execution");
335
335
  };
336
336
 
337
337
  try {
@@ -339,7 +339,7 @@ Runnable.prototype.run = function (fn) {
339
339
  } catch (err) {
340
340
  // handles async runnables which actually run synchronously
341
341
  errorWasHandled = true;
342
- if (err instanceof Pending) {
342
+ if (err instanceof PendingError) {
343
343
  return; // done() is already called in this.skip()
344
344
  } else if (this.allowUncaught) {
345
345
  throw err;
@@ -354,7 +354,7 @@ Runnable.prototype.run = function (fn) {
354
354
  callFn(this.fn);
355
355
  } catch (err) {
356
356
  errorWasHandled = true;
357
- if (err instanceof Pending) {
357
+ if (err instanceof PendingError) {
358
358
  return done();
359
359
  } else if (this.allowUncaught) {
360
360
  throw err;
package/lib/runner.js CHANGED
@@ -9,7 +9,7 @@
9
9
  * @private
10
10
  */
11
11
  var EventEmitter = require("node:events").EventEmitter;
12
- var Pending = require("./pending");
12
+ var PendingError = require("./pending");
13
13
  var utils = require("./utils");
14
14
  var debug = require("debug")("mocha:runner");
15
15
  var Runnable = require("./runnable");
@@ -1105,8 +1105,8 @@ Runner.prototype._uncaught = function (err) {
1105
1105
  this,
1106
1106
  );
1107
1107
  }
1108
- if (err instanceof Pending) {
1109
- debug("uncaught(): caught a Pending");
1108
+ if (err instanceof PendingError) {
1109
+ debug("uncaught(): caught a PendingError");
1110
1110
  return;
1111
1111
  }
1112
1112
  // browser does not exit script when throwing in global.onerror()