mocha 11.7.4 → 11.7.6

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.
Files changed (67) hide show
  1. package/bin/_mocha +2 -2
  2. package/bin/mocha.js +46 -44
  3. package/browser-entry.js +20 -20
  4. package/index.js +2 -2
  5. package/lib/browser/highlight-tags.js +6 -6
  6. package/lib/browser/parse-query.js +5 -5
  7. package/lib/browser/template.html +2 -2
  8. package/lib/cli/cli.js +32 -27
  9. package/lib/cli/collect-files.js +25 -25
  10. package/lib/cli/commands.js +4 -4
  11. package/lib/cli/config.js +26 -25
  12. package/lib/cli/index.js +2 -2
  13. package/lib/cli/init.js +19 -19
  14. package/lib/cli/lookup-files.js +20 -20
  15. package/lib/cli/node-flags.js +12 -12
  16. package/lib/cli/one-and-dones.js +12 -11
  17. package/lib/cli/options.js +49 -49
  18. package/lib/cli/run-helpers.js +52 -54
  19. package/lib/cli/run-option-metadata.js +75 -75
  20. package/lib/cli/run.js +164 -159
  21. package/lib/cli/watch-run.js +75 -75
  22. package/lib/context.js +1 -1
  23. package/lib/error-constants.js +17 -17
  24. package/lib/errors.js +26 -26
  25. package/lib/hook.js +9 -9
  26. package/lib/interfaces/bdd.js +8 -8
  27. package/lib/interfaces/common.js +12 -12
  28. package/lib/interfaces/exports.js +8 -8
  29. package/lib/interfaces/index.js +5 -5
  30. package/lib/interfaces/qunit.js +7 -7
  31. package/lib/interfaces/tdd.js +7 -7
  32. package/lib/mocha.js +97 -97
  33. package/lib/nodejs/buffered-worker-pool.js +30 -30
  34. package/lib/nodejs/esm-utils.js +24 -21
  35. package/lib/nodejs/file-unloader.js +2 -2
  36. package/lib/nodejs/parallel-buffered-runner.js +67 -67
  37. package/lib/nodejs/reporters/parallel-buffered.js +13 -10
  38. package/lib/nodejs/serializer.js +47 -47
  39. package/lib/nodejs/worker.js +38 -38
  40. package/lib/pending.js +1 -1
  41. package/lib/plugin-loader.js +48 -48
  42. package/lib/reporters/base.js +97 -94
  43. package/lib/reporters/doc.js +17 -17
  44. package/lib/reporters/dot.js +14 -14
  45. package/lib/reporters/html.js +73 -67
  46. package/lib/reporters/index.js +16 -16
  47. package/lib/reporters/json-stream.js +10 -10
  48. package/lib/reporters/json.js +16 -16
  49. package/lib/reporters/landing.js +20 -20
  50. package/lib/reporters/list.js +10 -10
  51. package/lib/reporters/markdown.js +21 -21
  52. package/lib/reporters/min.js +7 -7
  53. package/lib/reporters/nyan.js +35 -35
  54. package/lib/reporters/progress.js +14 -14
  55. package/lib/reporters/spec.js +15 -15
  56. package/lib/reporters/tap.js +26 -26
  57. package/lib/reporters/xunit.js +38 -34
  58. package/lib/runnable.js +41 -41
  59. package/lib/runner.js +105 -105
  60. package/lib/stats-collector.js +4 -4
  61. package/lib/suite.js +56 -46
  62. package/lib/test.js +10 -10
  63. package/lib/utils.js +122 -122
  64. package/mocha.css +68 -50
  65. package/mocha.js +826 -803
  66. package/mocha.js.map +1 -1
  67. package/package.json +8 -13
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  /**
4
4
  * @typedef {import('../runner.js')} Runner
@@ -12,8 +12,8 @@
12
12
  * Module dependencies.
13
13
  */
14
14
 
15
- var Base = require('./base');
16
- var constants = require('../runner').constants;
15
+ var Base = require("./base");
16
+ var constants = require("../runner").constants;
17
17
  var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
18
18
  var EVENT_RUN_END = constants.EVENT_RUN_END;
19
19
  var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
@@ -21,7 +21,7 @@ var EVENT_SUITE_END = constants.EVENT_SUITE_END;
21
21
  var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
22
22
  var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
23
23
  var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
24
- var inherits = require('../utils').inherits;
24
+ var inherits = require("../utils").inherits;
25
25
  var color = Base.color;
26
26
 
27
27
  /**
@@ -48,7 +48,7 @@ function Spec(runner, options) {
48
48
  var n = 0;
49
49
 
50
50
  function indent() {
51
- return Array(indents).join(' ');
51
+ return Array(indents).join(" ");
52
52
  }
53
53
 
54
54
  runner.on(EVENT_RUN_BEGIN, function () {
@@ -57,7 +57,7 @@ function Spec(runner, options) {
57
57
 
58
58
  runner.on(EVENT_SUITE_BEGIN, function (suite) {
59
59
  ++indents;
60
- Base.consoleLog(color('suite', '%s%s'), indent(), suite.title);
60
+ Base.consoleLog(color("suite", "%s%s"), indent(), suite.title);
61
61
  });
62
62
 
63
63
  runner.on(EVENT_SUITE_END, function () {
@@ -68,30 +68,30 @@ function Spec(runner, options) {
68
68
  });
69
69
 
70
70
  runner.on(EVENT_TEST_PENDING, function (test) {
71
- var fmt = indent() + color('pending', ' - %s');
71
+ var fmt = indent() + color("pending", " - %s");
72
72
  Base.consoleLog(fmt, test.title);
73
73
  });
74
74
 
75
75
  runner.on(EVENT_TEST_PASS, function (test) {
76
76
  var fmt;
77
- if (test.speed === 'fast') {
77
+ if (test.speed === "fast") {
78
78
  fmt =
79
79
  indent() +
80
- color('checkmark', ' ' + Base.symbols.ok) +
81
- color('pass', ' %s');
80
+ color("checkmark", " " + Base.symbols.ok) +
81
+ color("pass", " %s");
82
82
  Base.consoleLog(fmt, test.title);
83
83
  } else {
84
84
  fmt =
85
85
  indent() +
86
- color('checkmark', ' ' + Base.symbols.ok) +
87
- color('pass', ' %s') +
88
- color(test.speed, ' (%dms)');
86
+ color("checkmark", " " + Base.symbols.ok) +
87
+ color("pass", " %s") +
88
+ color(test.speed, " (%dms)");
89
89
  Base.consoleLog(fmt, test.title, test.duration);
90
90
  }
91
91
  });
92
92
 
93
93
  runner.on(EVENT_TEST_FAIL, function (test) {
94
- Base.consoleLog(indent() + color('fail', ' %d) %s'), ++n, test.title);
94
+ Base.consoleLog(indent() + color("fail", " %d) %s"), ++n, test.title);
95
95
  });
96
96
 
97
97
  runner.once(EVENT_RUN_END, self.epilogue.bind(self));
@@ -102,4 +102,4 @@ function Spec(runner, options) {
102
102
  */
103
103
  inherits(Spec, Base);
104
104
 
105
- Spec.description = 'hierarchical & verbose [default]';
105
+ Spec.description = "hierarchical & verbose [default]";
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  /**
4
4
  * @typedef {import('../runner.js')} Runner
@@ -12,16 +12,16 @@
12
12
  * Module dependencies.
13
13
  */
14
14
 
15
- var util = require('node:util');
16
- var Base = require('./base');
17
- var constants = require('../runner').constants;
15
+ var util = require("node:util");
16
+ var Base = require("./base");
17
+ var constants = require("../runner").constants;
18
18
  var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
19
19
  var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
20
20
  var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
21
21
  var EVENT_RUN_END = constants.EVENT_RUN_END;
22
22
  var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
23
23
  var EVENT_TEST_END = constants.EVENT_TEST_END;
24
- var inherits = require('../utils').inherits;
24
+ var inherits = require("../utils").inherits;
25
25
  var sprintf = util.format;
26
26
 
27
27
  /**
@@ -46,7 +46,7 @@ function TAP(runner, options) {
46
46
  var self = this;
47
47
  var n = 1;
48
48
 
49
- var tapVersion = '12';
49
+ var tapVersion = "12";
50
50
  if (options && options.reporterOptions) {
51
51
  if (options.reporterOptions.tapVersion) {
52
52
  tapVersion = options.reporterOptions.tapVersion.toString();
@@ -93,7 +93,7 @@ inherits(TAP, Base);
93
93
  * @return {String} title with any hash character removed
94
94
  */
95
95
  function title(test) {
96
- return test.fullTitle().replace(/#/g, '');
96
+ return test.fullTitle().replace(/#/g, "");
97
97
  }
98
98
 
99
99
  /**
@@ -105,7 +105,7 @@ function title(test) {
105
105
  */
106
106
  function println() {
107
107
  var vargs = Array.from(arguments);
108
- vargs[0] += '\n';
108
+ vargs[0] += "\n";
109
109
  process.stdout.write(sprintf.apply(null, vargs));
110
110
  }
111
111
 
@@ -120,13 +120,13 @@ function println() {
120
120
  function createProducer(tapVersion) {
121
121
  var producers = {
122
122
  12: new TAP12Producer(),
123
- 13: new TAP13Producer()
123
+ 13: new TAP13Producer(),
124
124
  };
125
125
  var producer = producers[tapVersion];
126
126
 
127
127
  if (!producer) {
128
128
  throw new Error(
129
- 'invalid or unsupported TAP version: ' + JSON.stringify(tapVersion)
129
+ "invalid or unsupported TAP version: " + JSON.stringify(tapVersion),
130
130
  );
131
131
  }
132
132
 
@@ -159,7 +159,7 @@ TAPProducer.prototype.writeVersion = function () {};
159
159
  * @param {number} ntests - Number of tests that are planned to run.
160
160
  */
161
161
  TAPProducer.prototype.writePlan = function (ntests) {
162
- println('%d..%d', 1, ntests);
162
+ println("%d..%d", 1, ntests);
163
163
  };
164
164
 
165
165
  /**
@@ -170,7 +170,7 @@ TAPProducer.prototype.writePlan = function (ntests) {
170
170
  * @param {Test} test - Instance containing test information.
171
171
  */
172
172
  TAPProducer.prototype.writePass = function (n, test) {
173
- println('ok %d %s', n, title(test));
173
+ println("ok %d %s", n, title(test));
174
174
  };
175
175
 
176
176
  /**
@@ -181,7 +181,7 @@ TAPProducer.prototype.writePass = function (n, test) {
181
181
  * @param {Test} test - Instance containing test information.
182
182
  */
183
183
  TAPProducer.prototype.writePending = function (n, test) {
184
- println('ok %d %s # SKIP -', n, title(test));
184
+ println("ok %d %s # SKIP -", n, title(test));
185
185
  };
186
186
 
187
187
  /**
@@ -192,7 +192,7 @@ TAPProducer.prototype.writePending = function (n, test) {
192
192
  * @param {Test} test - Instance containing test information.
193
193
  */
194
194
  TAPProducer.prototype.writeFail = function (n, test) {
195
- println('not ok %d %s', n, title(test));
195
+ println("not ok %d %s", n, title(test));
196
196
  };
197
197
 
198
198
  /**
@@ -203,10 +203,10 @@ TAPProducer.prototype.writeFail = function (n, test) {
203
203
  */
204
204
  TAPProducer.prototype.writeEpilogue = function (stats) {
205
205
  // :TBD: Why is this not counting pending tests?
206
- println('# tests ' + (stats.passes + stats.failures));
207
- println('# pass ' + stats.passes);
206
+ println("# tests " + (stats.passes + stats.failures));
207
+ println("# pass " + stats.passes);
208
208
  // :TBD: Why are we not showing pending results?
209
- println('# fail ' + stats.failures);
209
+ println("# fail " + stats.failures);
210
210
  this.writePlan(stats.passes + stats.failures + stats.pending);
211
211
  };
212
212
 
@@ -230,10 +230,10 @@ function TAP12Producer() {
230
230
  this.writeFail = function (n, test, err) {
231
231
  TAPProducer.prototype.writeFail.call(this, n, test, err);
232
232
  if (err.message) {
233
- println(err.message.replace(/^/gm, ' '));
233
+ println(err.message.replace(/^/gm, " "));
234
234
  }
235
235
  if (err.stack) {
236
- println(err.stack.replace(/^/gm, ' '));
236
+ println(err.stack.replace(/^/gm, " "));
237
237
  }
238
238
  };
239
239
  }
@@ -261,7 +261,7 @@ function TAP13Producer() {
261
261
  * @override
262
262
  */
263
263
  this.writeVersion = function () {
264
- println('TAP version 13');
264
+ println("TAP version 13");
265
265
  };
266
266
 
267
267
  /**
@@ -272,21 +272,21 @@ function TAP13Producer() {
272
272
  TAPProducer.prototype.writeFail.call(this, n, test, err);
273
273
  var emitYamlBlock = err.message != null || err.stack != null;
274
274
  if (emitYamlBlock) {
275
- println(indent(1) + '---');
275
+ println(indent(1) + "---");
276
276
  if (err.message) {
277
- println(indent(2) + 'message: |-');
277
+ println(indent(2) + "message: |-");
278
278
  println(err.message.replace(/^/gm, indent(3)));
279
279
  }
280
280
  if (err.stack) {
281
- println(indent(2) + 'stack: |-');
281
+ println(indent(2) + "stack: |-");
282
282
  println(err.stack.replace(/^/gm, indent(3)));
283
283
  }
284
- println(indent(1) + '...');
284
+ println(indent(1) + "...");
285
285
  }
286
286
  };
287
287
 
288
288
  function indent(level) {
289
- return Array(level + 1).join(' ');
289
+ return Array(level + 1).join(" ");
290
290
  }
291
291
  }
292
292
 
@@ -295,4 +295,4 @@ function TAP13Producer() {
295
295
  */
296
296
  inherits(TAP13Producer, TAPProducer);
297
297
 
298
- TAP.description = 'TAP-compatible output';
298
+ TAP.description = "TAP-compatible output";
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  /**
4
4
  * @typedef {import('../runner.js')} Runner
@@ -12,18 +12,18 @@
12
12
  * Module dependencies.
13
13
  */
14
14
 
15
- var Base = require('./base');
16
- var utils = require('../utils');
17
- var fs = require('node:fs');
18
- var path = require('node:path');
19
- var errors = require('../errors');
15
+ var Base = require("./base");
16
+ var utils = require("../utils");
17
+ var fs = require("node:fs");
18
+ var path = require("node:path");
19
+ var errors = require("../errors");
20
20
  var createUnsupportedError = errors.createUnsupportedError;
21
- var constants = require('../runner').constants;
21
+ var constants = require("../runner").constants;
22
22
  var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
23
23
  var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
24
24
  var EVENT_RUN_END = constants.EVENT_RUN_END;
25
25
  var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
26
- var STATE_FAILED = require('../runnable').constants.STATE_FAILED;
26
+ var STATE_FAILED = require("../runnable").constants.STATE_FAILED;
27
27
  var inherits = utils.inherits;
28
28
  var escape = utils.escape;
29
29
 
@@ -59,16 +59,16 @@ function XUnit(runner, options) {
59
59
  var suiteName;
60
60
 
61
61
  // the default name of the test suite if none is provided
62
- var DEFAULT_SUITE_NAME = 'Mocha Tests';
62
+ var DEFAULT_SUITE_NAME = "Mocha Tests";
63
63
 
64
64
  if (options && options.reporterOptions) {
65
65
  if (options.reporterOptions.output) {
66
66
  if (!fs.createWriteStream) {
67
- throw createUnsupportedError('file output not supported in browser');
67
+ throw createUnsupportedError("file output not supported in browser");
68
68
  }
69
69
 
70
70
  fs.mkdirSync(path.dirname(options.reporterOptions.output), {
71
- recursive: true
71
+ recursive: true,
72
72
  });
73
73
  self.fileStream = fs.createWriteStream(options.reporterOptions.output);
74
74
  }
@@ -95,7 +95,7 @@ function XUnit(runner, options) {
95
95
  runner.once(EVENT_RUN_END, function () {
96
96
  self.write(
97
97
  tag(
98
- 'testsuite',
98
+ "testsuite",
99
99
  {
100
100
  name: suiteName,
101
101
  tests: stats.tests,
@@ -103,17 +103,17 @@ function XUnit(runner, options) {
103
103
  errors: stats.failures,
104
104
  skipped: stats.tests - stats.failures - stats.passes,
105
105
  timestamp: new Date().toUTCString(),
106
- time: stats.duration / 1000 || 0
106
+ time: stats.duration / 1000 || 0,
107
107
  },
108
- false
109
- )
108
+ false,
109
+ ),
110
110
  );
111
111
 
112
112
  tests.forEach(function (t) {
113
113
  self.test(t, options);
114
114
  });
115
115
 
116
- self.write('</testsuite>');
116
+ self.write("</testsuite>");
117
117
  });
118
118
  }
119
119
 
@@ -145,9 +145,9 @@ XUnit.prototype.done = function (failures, fn) {
145
145
  */
146
146
  XUnit.prototype.write = function (line) {
147
147
  if (this.fileStream) {
148
- this.fileStream.write(line + '\n');
149
- } else if (typeof process === 'object' && process.stdout) {
150
- process.stdout.write(line + '\n');
148
+ this.fileStream.write(line + "\n");
149
+ } else if (typeof process === "object" && process.stdout) {
150
+ process.stdout.write(line + "\n");
151
151
  } else {
152
152
  Base.consoleLog(line);
153
153
  }
@@ -165,32 +165,32 @@ XUnit.prototype.test = function (test, options) {
165
165
  classname: test.parent.fullTitle(),
166
166
  name: test.title,
167
167
  file: testFilePath(test.file, options),
168
- time: test.duration / 1000 || 0
168
+ time: test.duration / 1000 || 0,
169
169
  };
170
170
 
171
171
  if (test.state === STATE_FAILED) {
172
172
  var err = test.err;
173
173
  var diff =
174
174
  !Base.hideDiff && Base.showDiff(err)
175
- ? '\n' + Base.generateDiff(err.actual, err.expected)
176
- : '';
175
+ ? "\n" + Base.generateDiff(err.actual, err.expected)
176
+ : "";
177
177
  this.write(
178
178
  tag(
179
- 'testcase',
179
+ "testcase",
180
180
  attrs,
181
181
  false,
182
182
  tag(
183
- 'failure',
183
+ "failure",
184
184
  {},
185
185
  false,
186
- escape(err.message) + escape(diff) + '\n' + escape(err.stack)
187
- )
188
- )
186
+ escape(err.message) + escape(diff) + "\n" + escape(err.stack),
187
+ ),
188
+ ),
189
189
  );
190
190
  } else if (test.isPending()) {
191
- this.write(tag('testcase', attrs, false, tag('skipped', {}, true)));
191
+ this.write(tag("testcase", attrs, false, tag("skipped", {}, true)));
192
192
  } else {
193
- this.write(tag('testcase', attrs, true));
193
+ this.write(tag("testcase", attrs, true));
194
194
  }
195
195
  };
196
196
 
@@ -204,7 +204,7 @@ XUnit.prototype.test = function (test, options) {
204
204
  * @return {string}
205
205
  */
206
206
  function tag(name, attrs, close, content) {
207
- var end = close ? '/>' : '>';
207
+ var end = close ? "/>" : ">";
208
208
  var pairs = [];
209
209
  var tag;
210
210
 
@@ -214,19 +214,23 @@ function tag(name, attrs, close, content) {
214
214
  }
215
215
  }
216
216
 
217
- tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end;
217
+ tag = "<" + name + (pairs.length ? " " + pairs.join(" ") : "") + end;
218
218
  if (content) {
219
- tag += content + '</' + name + end;
219
+ tag += content + "</" + name + end;
220
220
  }
221
221
  return tag;
222
222
  }
223
223
 
224
224
  function testFilePath(filepath, options) {
225
- if (options && options.reporterOptions && options.reporterOptions.showRelativePaths) {
225
+ if (
226
+ options &&
227
+ options.reporterOptions &&
228
+ options.reporterOptions.showRelativePaths
229
+ ) {
226
230
  return path.relative(process.cwd(), filepath);
227
231
  }
228
232
 
229
233
  return filepath;
230
234
  }
231
235
 
232
- XUnit.description = 'XUnit-compatible XML output';
236
+ XUnit.description = "XUnit-compatible XML output";
package/lib/runnable.js CHANGED
@@ -1,15 +1,15 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var EventEmitter = require('node:events').EventEmitter;
4
- var Pending = require('./pending');
5
- var debug = require('debug')('mocha:runnable');
6
- var milliseconds = require('ms');
7
- var utils = require('./utils');
3
+ var EventEmitter = require("node:events").EventEmitter;
4
+ var Pending = require("./pending");
5
+ var debug = require("debug")("mocha:runnable");
6
+ var milliseconds = require("ms");
7
+ var utils = require("./utils");
8
8
  const {
9
9
  createInvalidExceptionError,
10
10
  createMultipleDoneError,
11
- createTimeoutError
12
- } = require('./errors');
11
+ createTimeoutError,
12
+ } = require("./errors");
13
13
 
14
14
  /**
15
15
  * Save timer references to avoid Sinon interfering (see GH-237).
@@ -38,17 +38,17 @@ module.exports = Runnable;
38
38
  function Runnable(title, fn) {
39
39
  this.title = title;
40
40
  this.fn = fn;
41
- this.body = (fn || '').toString();
41
+ this.body = (fn || "").toString();
42
42
  this.async = fn && fn.length;
43
43
  this.sync = !this.async;
44
44
  this._timeout = 2000;
45
45
  this._slow = 75;
46
46
  this._retries = -1;
47
47
  utils.assignNewMochaID(this);
48
- Object.defineProperty(this, 'id', {
48
+ Object.defineProperty(this, "id", {
49
49
  get() {
50
50
  return utils.getMochaID(this);
51
- }
51
+ },
52
52
  });
53
53
  this.reset();
54
54
  }
@@ -94,7 +94,7 @@ Runnable.prototype.timeout = function (ms) {
94
94
  if (!arguments.length) {
95
95
  return this._timeout;
96
96
  }
97
- if (typeof ms === 'string') {
97
+ if (typeof ms === "string") {
98
98
  ms = milliseconds(ms);
99
99
  }
100
100
 
@@ -108,7 +108,7 @@ Runnable.prototype.timeout = function (ms) {
108
108
  } else {
109
109
  this._timeout = ms;
110
110
  }
111
- debug('timeout %d', this._timeout);
111
+ debug("timeout %d", this._timeout);
112
112
 
113
113
  if (this.timer) {
114
114
  this.resetTimeout();
@@ -124,13 +124,13 @@ Runnable.prototype.timeout = function (ms) {
124
124
  * @return {Runnable|number} ms or Runnable instance.
125
125
  */
126
126
  Runnable.prototype.slow = function (ms) {
127
- if (!arguments.length || typeof ms === 'undefined') {
127
+ if (!arguments.length || typeof ms === "undefined") {
128
128
  return this._slow;
129
129
  }
130
- if (typeof ms === 'string') {
130
+ if (typeof ms === "string") {
131
131
  ms = milliseconds(ms);
132
132
  }
133
- debug('slow %d', ms);
133
+ debug("slow %d", ms);
134
134
  this._slow = ms;
135
135
  return this;
136
136
  };
@@ -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 Pending("sync skip; aborting execution");
147
147
  };
148
148
 
149
149
  /**
@@ -206,7 +206,7 @@ Runnable.prototype.currentRetry = function (n) {
206
206
  * @return {string}
207
207
  */
208
208
  Runnable.prototype.fullTitle = function () {
209
- return this.titlePath().join(' ');
209
+ return this.titlePath().join(" ");
210
210
  };
211
211
 
212
212
  /**
@@ -287,7 +287,7 @@ Runnable.prototype.run = function (fn) {
287
287
  return;
288
288
  }
289
289
  errorWasHandled = true;
290
- self.emit('error', createMultipleDoneError(self, err));
290
+ self.emit("error", createMultipleDoneError(self, err));
291
291
  }
292
292
 
293
293
  // finished
@@ -313,11 +313,11 @@ Runnable.prototype.run = function (fn) {
313
313
  // for .resetTimeout() and Runner#uncaught()
314
314
  this.callback = done;
315
315
 
316
- if (this.fn && typeof this.fn.call !== 'function') {
316
+ if (this.fn && typeof this.fn.call !== "function") {
317
317
  done(
318
318
  new TypeError(
319
- 'A runnable must be passed a function as its second argument.'
320
- )
319
+ "A runnable must be passed a function as its second argument.",
320
+ ),
321
321
  );
322
322
  return;
323
323
  }
@@ -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 Pending("async skip; aborting execution");
335
335
  };
336
336
 
337
337
  try {
@@ -364,7 +364,7 @@ Runnable.prototype.run = function (fn) {
364
364
 
365
365
  function callFn(fn) {
366
366
  var result = fn.call(ctx);
367
- if (result && typeof result.then === 'function') {
367
+ if (result && typeof result.then === "function") {
368
368
  self.resetTimeout();
369
369
  result.then(
370
370
  function () {
@@ -374,15 +374,15 @@ Runnable.prototype.run = function (fn) {
374
374
  return null;
375
375
  },
376
376
  function (reason) {
377
- done(reason || new Error('Promise rejected with no or falsy reason'));
378
- }
377
+ done(reason || new Error("Promise rejected with no or falsy reason"));
378
+ },
379
379
  );
380
380
  } else {
381
381
  if (self.asyncOnly) {
382
382
  return done(
383
383
  new Error(
384
- '--async-only option in use without declaring `done()` or returning a promise'
385
- )
384
+ "--async-only option in use without declaring `done()` or returning a promise",
385
+ ),
386
386
  );
387
387
  }
388
388
 
@@ -392,22 +392,22 @@ Runnable.prototype.run = function (fn) {
392
392
 
393
393
  function callFnAsync(fn) {
394
394
  var result = fn.call(ctx, function (err) {
395
- if (err instanceof Error || toString.call(err) === '[object Error]') {
395
+ if (err instanceof Error || toString.call(err) === "[object Error]") {
396
396
  return done(err);
397
397
  }
398
398
  if (err) {
399
- if (Object.prototype.toString.call(err) === '[object Object]') {
399
+ if (Object.prototype.toString.call(err) === "[object Object]") {
400
400
  return done(
401
- new Error('done() invoked with non-Error: ' + JSON.stringify(err))
401
+ new Error("done() invoked with non-Error: " + JSON.stringify(err)),
402
402
  );
403
403
  }
404
- return done(new Error('done() invoked with non-Error: ' + err));
404
+ return done(new Error("done() invoked with non-Error: " + err));
405
405
  }
406
406
  if (result && utils.isPromise(result)) {
407
407
  return done(
408
408
  new Error(
409
- 'Resolution method is overspecified. Specify a callback *or* return a Promise; not both.'
410
- )
409
+ "Resolution method is overspecified. Specify a callback *or* return a Promise; not both.",
410
+ ),
411
411
  );
412
412
  }
413
413
 
@@ -426,7 +426,7 @@ Runnable.prototype.run = function (fn) {
426
426
  Runnable.prototype._timeoutError = function (ms) {
427
427
  let msg = `Timeout of ${ms}ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.`;
428
428
  if (this.file) {
429
- msg += ' (' + this.file + ')';
429
+ msg += " (" + this.file + ")";
430
430
  }
431
431
  return createTimeoutError(msg, ms, this.file);
432
432
  };
@@ -445,16 +445,16 @@ var constants = utils.defineConstants(
445
445
  /**
446
446
  * Value of `state` prop when a `Runnable` has failed
447
447
  */
448
- STATE_FAILED: 'failed',
448
+ STATE_FAILED: "failed",
449
449
  /**
450
450
  * Value of `state` prop when a `Runnable` has passed
451
451
  */
452
- STATE_PASSED: 'passed',
452
+ STATE_PASSED: "passed",
453
453
  /**
454
454
  * Value of `state` prop when a `Runnable` has been skipped by user
455
455
  */
456
- STATE_PENDING: 'pending'
457
- }
456
+ STATE_PENDING: "pending",
457
+ },
458
458
  );
459
459
 
460
460
  /**
@@ -467,8 +467,8 @@ Runnable.toValueOrError = function (value) {
467
467
  return (
468
468
  value ||
469
469
  createInvalidExceptionError(
470
- 'Runnable failed with falsy or undefined exception. Please throw an Error instead.',
471
- value
470
+ "Runnable failed with falsy or undefined exception. Please throw an Error instead.",
471
+ value,
472
472
  )
473
473
  );
474
474
  };