mocha 10.8.0 → 10.8.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.
@@ -181,8 +181,24 @@ const loadPkgRc = (args = {}) => {
181
181
  result = {};
182
182
  const filepath = args.package || findUp.sync(mocharc.package);
183
183
  if (filepath) {
184
+ let configData;
184
185
  try {
185
- const pkg = JSON.parse(fs.readFileSync(filepath, 'utf8'));
186
+ configData = fs.readFileSync(filepath, 'utf8');
187
+ } catch (err) {
188
+ // If `args.package` was explicitly specified, throw an error
189
+ if (filepath == args.package) {
190
+ throw createUnparsableFileError(
191
+ `Unable to read ${filepath}: ${err}`,
192
+ filepath
193
+ );
194
+ } else {
195
+ debug('failed to read default package.json at %s; ignoring',
196
+ filepath);
197
+ return result;
198
+ }
199
+ }
200
+ try {
201
+ const pkg = JSON.parse(configData);
186
202
  if (pkg.mocha) {
187
203
  debug('`mocha` prop of package.json parsed: %O', pkg.mocha);
188
204
  result = pkg.mocha;
@@ -190,13 +206,11 @@ const loadPkgRc = (args = {}) => {
190
206
  debug('no config found in %s', filepath);
191
207
  }
192
208
  } catch (err) {
193
- if (args.package) {
194
- throw createUnparsableFileError(
195
- `Unable to read/parse ${filepath}: ${err}`,
196
- filepath
197
- );
198
- }
199
- debug('failed to read default package.json at %s; ignoring', filepath);
209
+ // If JSON failed to parse, throw an error.
210
+ throw createUnparsableFileError(
211
+ `Unable to parse ${filepath}: ${err}`,
212
+ filepath
213
+ );
200
214
  }
201
215
  }
202
216
  return result;
@@ -262,9 +262,15 @@ class SerializableEvent {
262
262
  breakCircularDeps(result.error);
263
263
 
264
264
  const pairs = Object.keys(result).map(key => [result, key]);
265
-
265
+ const seenPairs = new Set();
266
266
  let pair;
267
+
267
268
  while ((pair = pairs.shift())) {
269
+ if (seenPairs.has(pair[1])) {
270
+ continue;
271
+ }
272
+
273
+ seenPairs.add(pair[1]);
268
274
  SerializableEvent._serialize(pairs, ...pair);
269
275
  }
270
276
 
@@ -285,16 +285,16 @@ function HTML(runner, options) {
285
285
  function makeUrl(s) {
286
286
  var search = window.location.search;
287
287
 
288
- // Remove previous grep query parameter if present
288
+ // Remove previous {grep, fgrep, invert} query parameters if present
289
289
  if (search) {
290
- search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');
290
+ search = search.replace(/[?&](?:f?grep|invert)=[^&\s]*/g, '').replace(/^&/, '?');
291
291
  }
292
292
 
293
293
  return (
294
294
  window.location.pathname +
295
295
  (search ? search + '&' : '?') +
296
296
  'grep=' +
297
- encodeURIComponent(escapeRe(s))
297
+ encodeURIComponent(s)
298
298
  );
299
299
  }
300
300
 
@@ -304,7 +304,7 @@ function makeUrl(s) {
304
304
  * @param {Object} [suite]
305
305
  */
306
306
  HTML.prototype.suiteURL = function (suite) {
307
- return makeUrl(suite.fullTitle());
307
+ return makeUrl('^' + escapeRe(suite.fullTitle()) + ' ');
308
308
  };
309
309
 
310
310
  /**
@@ -313,7 +313,7 @@ HTML.prototype.suiteURL = function (suite) {
313
313
  * @param {Object} [test]
314
314
  */
315
315
  HTML.prototype.testURL = function (test) {
316
- return makeUrl(test.fullTitle());
316
+ return makeUrl('^' + escapeRe(test.fullTitle()) + '$');
317
317
  };
318
318
 
319
319
  /**
package/lib/utils.js CHANGED
@@ -675,7 +675,9 @@ exports.breakCircularDeps = inputObj => {
675
675
 
676
676
  seen.add(obj);
677
677
  for (const k in obj) {
678
- if (Object.prototype.hasOwnProperty.call(obj, k)) {
678
+ const descriptor = Object.getOwnPropertyDescriptor(obj, k);
679
+
680
+ if (descriptor && descriptor.writable) {
679
681
  obj[k] = _breakCircularDeps(obj[k], k);
680
682
  }
681
683
  }
package/mocha.js CHANGED
@@ -1,4 +1,4 @@
1
- // mocha@10.8.0 in javascript ES2018
1
+ // mocha@10.8.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) :
@@ -11638,7 +11638,9 @@
11638
11638
 
11639
11639
  seen.add(obj);
11640
11640
  for (const k in obj) {
11641
- if (Object.prototype.hasOwnProperty.call(obj, k)) {
11641
+ const descriptor = Object.getOwnPropertyDescriptor(obj, k);
11642
+
11643
+ if (descriptor && descriptor.writable) {
11642
11644
  obj[k] = _breakCircularDeps(obj[k]);
11643
11645
  }
11644
11646
  }
@@ -16981,16 +16983,16 @@
16981
16983
  function makeUrl(s) {
16982
16984
  var search = window.location.search;
16983
16985
 
16984
- // Remove previous grep query parameter if present
16986
+ // Remove previous {grep, fgrep, invert} query parameters if present
16985
16987
  if (search) {
16986
- search = search.replace(/[?&]grep=[^&\s]*/g, '').replace(/^&/, '?');
16988
+ search = search.replace(/[?&](?:f?grep|invert)=[^&\s]*/g, '').replace(/^&/, '?');
16987
16989
  }
16988
16990
 
16989
16991
  return (
16990
16992
  window.location.pathname +
16991
16993
  (search ? search + '&' : '?') +
16992
16994
  'grep=' +
16993
- encodeURIComponent(escapeRe(s))
16995
+ encodeURIComponent(s)
16994
16996
  );
16995
16997
  }
16996
16998
 
@@ -17000,7 +17002,7 @@
17000
17002
  * @param {Object} [suite]
17001
17003
  */
17002
17004
  HTML.prototype.suiteURL = function (suite) {
17003
- return makeUrl(suite.fullTitle());
17005
+ return makeUrl('^' + escapeRe(suite.fullTitle()) + ' ');
17004
17006
  };
17005
17007
 
17006
17008
  /**
@@ -17009,7 +17011,7 @@
17009
17011
  * @param {Object} [test]
17010
17012
  */
17011
17013
  HTML.prototype.testURL = function (test) {
17012
- return makeUrl(test.fullTitle());
17014
+ return makeUrl('^' + escapeRe(test.fullTitle()) + '$');
17013
17015
  };
17014
17016
 
17015
17017
  /**
@@ -19199,7 +19201,7 @@
19199
19201
  };
19200
19202
 
19201
19203
  var name = "mocha";
19202
- var version = "10.8.0";
19204
+ var version = "10.8.2";
19203
19205
  var homepage = "https://mochajs.org/";
19204
19206
  var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
19205
19207
  var require$$17 = {