mocha 5.0.4 → 5.0.5

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/CHANGELOG.md CHANGED
@@ -1,3 +1,37 @@
1
+ # 5.0.5 / 2018-03-22
2
+
3
+ Welcome [@outsideris] to the team!
4
+
5
+ ## :bug: Fixes
6
+
7
+ - [#3096]: Fix `--bail` failing to bail within hooks ([@outsideris])
8
+ - [#3184]: Don't skip too many suites (using `describe.skip()`) ([@outsideris])
9
+
10
+ ## :book: Documentation
11
+
12
+ - [#3133]: Improve docs regarding "pending" behavior ([@ematicipo])
13
+ - [#3276], [#3274]: Fix broken stuff in `CHANGELOG.md` ([@tagoro9], [@honzajavorek])
14
+
15
+ ## :nut_and_bolt: Other
16
+
17
+ - [#3208]: Improve test coverage for AMD users ([@outsideris])
18
+ - [#3267]: Remove vestiges of PhantomJS from CI ([@anishkny])
19
+ - [#2952]: Fix a debug message ([@boneskull])
20
+
21
+ [#3096]: https://github.com/mochajs/mocha/issues/3096
22
+ [#3184]: https://github.com/mochajs/mocha/issues/3184
23
+ [#3133]: https://github.com/mochajs/mocha/issues/3133
24
+ [#3276]: https://github.com/mochajs/mocha/pull/3276
25
+ [#3274]: https://github.com/mochajs/mocha/pull/3274
26
+ [#3208]: https://github.com/mochajs/mocha/issues/3208
27
+ [#2952]: https://github.com/mochajs/mocha/issues/2952
28
+ [#3267]: https://github.com/mochajs/mocha/pull/3267
29
+
30
+ [@ematicipo]: https://github.com/ematicipo
31
+ [@tagoro9]: https://github.com/tagoro9
32
+ [@honzajavorek]: https://github.com/honajavorek
33
+ [@anishkny]: https://github.com/anishkny
34
+
1
35
  # 5.0.4 / 2018-03-07
2
36
 
3
37
  ## :bug: Fixes
@@ -52,7 +86,7 @@ This release fixes a class of tests which report as *false positives*. **Certai
52
86
  **Maintainers of external reporters**: *If* a test of this class is encountered, the `Runner` instance will emit the `end` event *twice*; you *may* need to change your reporter to use `runner.once('end')` intead of `runner.on('end')`.
53
87
  - [#3093]: Fix stack trace reformatting problem ([@outsideris])
54
88
 
55
- ## :nut_and_bolt Other
89
+ ## :nut_and_bolt: Other
56
90
 
57
91
  - [#3248]: Update `browser-stdout` to v1.3.1 ([@honzajavorek])
58
92
 
@@ -87,10 +121,10 @@ Special thanks to [Wallaby.js](https://wallabyjs.com) for their continued suppor
87
121
  [#3119]: https://github.com/mochajs/mocha/issues/3119
88
122
  [#3132]: https://github.com/mochajs/mocha/issues/3132
89
123
  [#3098]: https://github.com/mochajs/mocha/issues/3098
90
- [#3212]: https://github.com/mochajs/mocha/pulls/3212
91
- [#3205]: https://github.com/mochajs/mocha/pulls/3205
92
- [#3224]: https://github.com/mochajs/mocha/pulls/3224
93
- [#3230]: https://github.com/mochajs/mocha/pulls/3230
124
+ [#3212]: https://github.com/mochajs/mocha/pull/3212
125
+ [#3205]: https://github.com/mochajs/mocha/pull/3205
126
+ [#3224]: https://github.com/mochajs/mocha/pull/3224
127
+ [#3230]: https://github.com/mochajs/mocha/pull/3230
94
128
  [@silviom]: https://github.com/silviom
95
129
  [@outsideris]: https://github.com/outsideris
96
130
  [@ArtemGovorov]: https://github.com/ArtemGovorov
@@ -350,9 +384,9 @@ For more info, please [read this article](https://boneskull.com/mocha-v4-nears-r
350
384
  - Various CI-and-test-related fixes and improvements ([@boneskull], [@dasilvacontin], [@PopradiArpad], [@Munter], [@ScottFreeCode])
351
385
  - "Officially" support Node.js 8 ([@elergy])
352
386
 
353
- [#2860]: https://github.com/mochajs/mocha/pulls/2860
354
- [#2696]: https://github.com/mochajs/mocha/pulls/2696
355
- [#2813]: https://github.com/mochajs/mocha/pulls/2813
387
+ [#2860]: https://github.com/mochajs/mocha/pull/2860
388
+ [#2696]: https://github.com/mochajs/mocha/pull/2696
389
+ [#2813]: https://github.com/mochajs/mocha/pull/2813
356
390
  [@charlierudolph]: https://github.com/charlierudolph
357
391
  [@PopradiArpad]: https://github.com/PopradiArpad
358
392
  [@kungapal]: https://github.com/kungapal
@@ -374,7 +408,7 @@ For more info, please [read this article](https://boneskull.com/mocha-v4-nears-r
374
408
  [@makepanic]: https://github.com/makepanic
375
409
  [@Munter]: https://github.com/Munter
376
410
 
377
- [#2778]: https://github.com/mochajs/mocha/pulls/2778
411
+ [#2778]: https://github.com/mochajs/mocha/pull/2778
378
412
  [#2802]: https://github.com/mochajs/mocha/issues/2802
379
413
  [#2820]: https://github.com/mochajs/mocha/pull/2820
380
414
 
@@ -113,6 +113,8 @@ module.exports = function (suites, context, mocha) {
113
113
  suites.shift();
114
114
  } else if (typeof opts.fn === 'undefined' && !suite.pending) {
115
115
  throw new Error('Suite "' + suite.fullTitle() + '" was defined but no callback was supplied. Supply a callback or explicitly skip the suite.');
116
+ } else if (!opts.fn && suite.pending) {
117
+ suites.shift();
116
118
  }
117
119
 
118
120
  return suite;
package/lib/runnable.js CHANGED
@@ -103,7 +103,7 @@ Runnable.prototype.slow = function (ms) {
103
103
  if (typeof ms === 'string') {
104
104
  ms = milliseconds(ms);
105
105
  }
106
- debug('timeout %d', ms);
106
+ debug('slow %d', ms);
107
107
  this._slow = ms;
108
108
  return this;
109
109
  };
package/lib/runner.js CHANGED
@@ -265,10 +265,10 @@ Runner.prototype.failHook = function (hook, err) {
265
265
  hook.title = hook.originalTitle + ' for "' + hook.ctx.currentTest.title + '"';
266
266
  }
267
267
 
268
- this.fail(hook, err);
269
268
  if (this.suite.bail()) {
270
269
  this.emit('end');
271
270
  }
271
+ this.fail(hook, err);
272
272
  };
273
273
 
274
274
  /**
package/mocha.js CHANGED
@@ -718,6 +718,8 @@ module.exports = function (suites, context, mocha) {
718
718
  suites.shift();
719
719
  } else if (typeof opts.fn === 'undefined' && !suite.pending) {
720
720
  throw new Error('Suite "' + suite.fullTitle() + '" was defined but no callback was supplied. Supply a callback or explicitly skip the suite.');
721
+ } else if (!opts.fn && suite.pending) {
722
+ suites.shift();
721
723
  }
722
724
 
723
725
  return suite;
@@ -4030,7 +4032,7 @@ Runnable.prototype.slow = function (ms) {
4030
4032
  if (typeof ms === 'string') {
4031
4033
  ms = milliseconds(ms);
4032
4034
  }
4033
- debug('timeout %d', ms);
4035
+ debug('slow %d', ms);
4034
4036
  this._slow = ms;
4035
4037
  return this;
4036
4038
  };
@@ -4615,10 +4617,10 @@ Runner.prototype.failHook = function (hook, err) {
4615
4617
  hook.title = hook.originalTitle + ' for "' + hook.ctx.currentTest.title + '"';
4616
4618
  }
4617
4619
 
4618
- this.fail(hook, err);
4619
4620
  if (this.suite.bail()) {
4620
4621
  this.emit('end');
4621
4622
  }
4623
+ this.fail(hook, err);
4622
4624
  };
4623
4625
 
4624
4626
  /**
@@ -8827,7 +8829,7 @@ function coerce(val) {
8827
8829
  },{"ms":54}],45:[function(require,module,exports){
8828
8830
  /*!
8829
8831
 
8830
- diff v3.3.1
8832
+ diff v3.5.0
8831
8833
 
8832
8834
  Software License Agreement (BSD License)
8833
8835
 
@@ -9150,7 +9152,11 @@ return /******/ (function(modules) { // webpackBootstrap
9150
9152
  return oldPos;
9151
9153
  },
9152
9154
  /*istanbul ignore start*/ /*istanbul ignore end*/equals: function equals(left, right) {
9153
- return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
9155
+ if (this.options.comparator) {
9156
+ return this.options.comparator(left, right);
9157
+ } else {
9158
+ return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
9159
+ }
9154
9160
  },
9155
9161
  /*istanbul ignore start*/ /*istanbul ignore end*/removeEmpty: function removeEmpty(array) {
9156
9162
  var ret = [];
@@ -9213,10 +9219,11 @@ return /******/ (function(modules) { // webpackBootstrap
9213
9219
  }
9214
9220
  }
9215
9221
 
9216
- // Special case handle for when one terminal is ignored. For this case we merge the
9217
- // terminal into the prior string and drop the change.
9222
+ // Special case handle for when one terminal is ignored (i.e. whitespace).
9223
+ // For this case we merge the terminal into the prior string and drop the change.
9224
+ // This is only available for string mode.
9218
9225
  var lastComponent = components[componentLen - 1];
9219
- if (componentLen > 1 && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
9226
+ if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
9220
9227
  components[componentLen - 2].value += lastComponent.value;
9221
9228
  components.pop();
9222
9229
  }
@@ -9494,16 +9501,16 @@ return /******/ (function(modules) { // webpackBootstrap
9494
9501
 
9495
9502
  jsonDiff.tokenize = /*istanbul ignore start*/_line.lineDiff /*istanbul ignore end*/.tokenize;
9496
9503
  jsonDiff.castInput = function (value) {
9497
- /*istanbul ignore start*/var /*istanbul ignore end*/undefinedReplacement = this.options.undefinedReplacement;
9498
-
9504
+ /*istanbul ignore start*/var _options = /*istanbul ignore end*/this.options,
9505
+ undefinedReplacement = _options.undefinedReplacement,
9506
+ _options$stringifyRep = _options.stringifyReplacer,
9507
+ stringifyReplacer = _options$stringifyRep === undefined ? function (k, v) /*istanbul ignore start*/{
9508
+ return (/*istanbul ignore end*/typeof v === 'undefined' ? undefinedReplacement : v
9509
+ );
9510
+ } : _options$stringifyRep;
9499
9511
 
9500
- return typeof value === 'string' ? value : JSON.stringify(canonicalize(value), function (k, v) {
9501
- if (typeof v === 'undefined') {
9502
- return undefinedReplacement;
9503
- }
9504
9512
 
9505
- return v;
9506
- }, ' ');
9513
+ return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
9507
9514
  };
9508
9515
  jsonDiff.equals = function (left, right) {
9509
9516
  return (/*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
@@ -9515,11 +9522,15 @@ return /******/ (function(modules) { // webpackBootstrap
9515
9522
  }
9516
9523
 
9517
9524
  // This function handles the presence of circular references by bailing out when encountering an
9518
- // object that is already on the "stack" of items being processed.
9519
- function canonicalize(obj, stack, replacementStack) {
9525
+ // object that is already on the "stack" of items being processed. Accepts an optional replacer
9526
+ function canonicalize(obj, stack, replacementStack, replacer, key) {
9520
9527
  stack = stack || [];
9521
9528
  replacementStack = replacementStack || [];
9522
9529
 
9530
+ if (replacer) {
9531
+ obj = replacer(key, obj);
9532
+ }
9533
+
9523
9534
  var i = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
9524
9535
 
9525
9536
  for (i = 0; i < stack.length; i += 1) {
@@ -9535,7 +9546,7 @@ return /******/ (function(modules) { // webpackBootstrap
9535
9546
  canonicalizedObj = new Array(obj.length);
9536
9547
  replacementStack.push(canonicalizedObj);
9537
9548
  for (i = 0; i < obj.length; i += 1) {
9538
- canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack);
9549
+ canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
9539
9550
  }
9540
9551
  stack.pop();
9541
9552
  replacementStack.pop();
@@ -9551,17 +9562,17 @@ return /******/ (function(modules) { // webpackBootstrap
9551
9562
  canonicalizedObj = {};
9552
9563
  replacementStack.push(canonicalizedObj);
9553
9564
  var sortedKeys = [],
9554
- key = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
9555
- for (key in obj) {
9565
+ _key = /*istanbul ignore start*/void 0 /*istanbul ignore end*/;
9566
+ for (_key in obj) {
9556
9567
  /* istanbul ignore else */
9557
- if (obj.hasOwnProperty(key)) {
9558
- sortedKeys.push(key);
9568
+ if (obj.hasOwnProperty(_key)) {
9569
+ sortedKeys.push(_key);
9559
9570
  }
9560
9571
  }
9561
9572
  sortedKeys.sort();
9562
9573
  for (i = 0; i < sortedKeys.length; i += 1) {
9563
- key = sortedKeys[i];
9564
- canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack);
9574
+ _key = sortedKeys[i];
9575
+ canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
9565
9576
  }
9566
9577
  stack.pop();
9567
9578
  replacementStack.pop();
@@ -9590,9 +9601,12 @@ return /******/ (function(modules) { // webpackBootstrap
9590
9601
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9591
9602
 
9592
9603
  /*istanbul ignore end*/var arrayDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/();
9593
- arrayDiff.tokenize = arrayDiff.join = function (value) {
9604
+ arrayDiff.tokenize = function (value) {
9594
9605
  return value.slice();
9595
9606
  };
9607
+ arrayDiff.join = arrayDiff.removeEmpty = function (value) {
9608
+ return value;
9609
+ };
9596
9610
 
9597
9611
  function diffArrays(oldArr, newArr, callback) {
9598
9612
  return arrayDiff.diff(oldArr, newArr, callback);
@@ -9654,8 +9668,8 @@ return /******/ (function(modules) { // webpackBootstrap
9654
9668
  function hunkFits(hunk, toPos) {
9655
9669
  for (var j = 0; j < hunk.lines.length; j++) {
9656
9670
  var line = hunk.lines[j],
9657
- operation = line[0],
9658
- content = line.substr(1);
9671
+ operation = line.length > 0 ? line[0] : ' ',
9672
+ content = line.length > 0 ? line.substr(1) : line;
9659
9673
 
9660
9674
  if (operation === ' ' || operation === '-') {
9661
9675
  // Context sanity check
@@ -9712,8 +9726,8 @@ return /******/ (function(modules) { // webpackBootstrap
9712
9726
 
9713
9727
  for (var j = 0; j < _hunk.lines.length; j++) {
9714
9728
  var line = _hunk.lines[j],
9715
- operation = line[0],
9716
- content = line.substr(1),
9729
+ operation = line.length > 0 ? line[0] : ' ',
9730
+ content = line.length > 0 ? line.substr(1) : line,
9717
9731
  delimiter = _hunk.linedelimiters[j];
9718
9732
 
9719
9733
  if (operation === ' ') {
@@ -9851,16 +9865,16 @@ return /******/ (function(modules) { // webpackBootstrap
9851
9865
  // Parses the --- and +++ headers, if none are found, no lines
9852
9866
  // are consumed.
9853
9867
  function parseFileHeader(index) {
9854
- var headerPattern = /^(---|\+\+\+)\s+([\S ]*)(?:\t(.*?)\s*)?$/;
9855
- var fileHeader = headerPattern.exec(diffstr[i]);
9868
+ var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
9856
9869
  if (fileHeader) {
9857
9870
  var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
9858
- var fileName = fileHeader[2].replace(/\\\\/g, '\\');
9871
+ var data = fileHeader[2].split('\t', 2);
9872
+ var fileName = data[0].replace(/\\\\/g, '\\');
9859
9873
  if (/^".*"$/.test(fileName)) {
9860
9874
  fileName = fileName.substr(1, fileName.length - 2);
9861
9875
  }
9862
9876
  index[keyPrefix + 'FileName'] = fileName;
9863
- index[keyPrefix + 'Header'] = fileHeader[3];
9877
+ index[keyPrefix + 'Header'] = (data[1] || '').trim();
9864
9878
 
9865
9879
  i++;
9866
9880
  }
@@ -9890,7 +9904,7 @@ return /******/ (function(modules) { // webpackBootstrap
9890
9904
  if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
9891
9905
  break;
9892
9906
  }
9893
- var operation = diffstr[i][0];
9907
+ var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
9894
9908
 
9895
9909
  if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
9896
9910
  hunk.lines.push(diffstr[i]);
@@ -10011,27 +10025,19 @@ return /******/ (function(modules) { // webpackBootstrap
10011
10025
  /*istanbul ignore start*/function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
10012
10026
 
10013
10027
  /*istanbul ignore end*/function calcLineCount(hunk) {
10014
- var conflicted = false;
10015
-
10016
- hunk.oldLines = 0;
10017
- hunk.newLines = 0;
10018
-
10019
- hunk.lines.forEach(function (line) {
10020
- if (typeof line !== 'string') {
10021
- conflicted = true;
10022
- return;
10023
- }
10024
-
10025
- if (line[0] === '+' || line[0] === ' ') {
10026
- hunk.newLines++;
10027
- }
10028
- if (line[0] === '-' || line[0] === ' ') {
10029
- hunk.oldLines++;
10030
- }
10031
- });
10028
+ /*istanbul ignore start*/var _calcOldNewLineCount = /*istanbul ignore end*/calcOldNewLineCount(hunk.lines),
10029
+ oldLines = _calcOldNewLineCount.oldLines,
10030
+ newLines = _calcOldNewLineCount.newLines;
10032
10031
 
10033
- if (conflicted) {
10032
+ if (oldLines !== undefined) {
10033
+ hunk.oldLines = oldLines;
10034
+ } else {
10034
10035
  delete hunk.oldLines;
10036
+ }
10037
+
10038
+ if (newLines !== undefined) {
10039
+ hunk.newLines = newLines;
10040
+ } else {
10035
10041
  delete hunk.newLines;
10036
10042
  }
10037
10043
  }
@@ -10363,6 +10369,43 @@ return /******/ (function(modules) { // webpackBootstrap
10363
10369
  return true;
10364
10370
  }
10365
10371
 
10372
+ function calcOldNewLineCount(lines) {
10373
+ var oldLines = 0;
10374
+ var newLines = 0;
10375
+
10376
+ lines.forEach(function (line) {
10377
+ if (typeof line !== 'string') {
10378
+ var myCount = calcOldNewLineCount(line.mine);
10379
+ var theirCount = calcOldNewLineCount(line.theirs);
10380
+
10381
+ if (oldLines !== undefined) {
10382
+ if (myCount.oldLines === theirCount.oldLines) {
10383
+ oldLines += myCount.oldLines;
10384
+ } else {
10385
+ oldLines = undefined;
10386
+ }
10387
+ }
10388
+
10389
+ if (newLines !== undefined) {
10390
+ if (myCount.newLines === theirCount.newLines) {
10391
+ newLines += myCount.newLines;
10392
+ } else {
10393
+ newLines = undefined;
10394
+ }
10395
+ }
10396
+ } else {
10397
+ if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
10398
+ newLines++;
10399
+ }
10400
+ if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
10401
+ oldLines++;
10402
+ }
10403
+ }
10404
+ });
10405
+
10406
+ return { oldLines: oldLines, newLines: newLines };
10407
+ }
10408
+
10366
10409
 
10367
10410
 
10368
10411
  /***/ }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mocha",
3
- "version": "5.0.4",
3
+ "version": "5.0.5",
4
4
  "description": "simple, flexible, fun test framework",
5
5
  "keywords": [
6
6
  "mocha",