mocha 12.0.0-beta-9 → 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/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;
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()