chai 4.3.0 → 4.3.4

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/README.md CHANGED
@@ -26,7 +26,7 @@
26
26
  <a href="https://www.npmjs.com/package/chai">
27
27
  <img
28
28
  alt="node:?"
29
- src="https://img.shields.io/badge/node-%3E=8.0-blue.svg?style=flat-square"
29
+ src="https://img.shields.io/badge/node-%3E=4.0-blue.svg?style=flat-square"
30
30
  />
31
31
  </a>
32
32
  <br/>
package/chai.js CHANGED
@@ -14,7 +14,7 @@ var used = [];
14
14
  * Chai version
15
15
  */
16
16
 
17
- exports.version = '4.3.0';
17
+ exports.version = '4.3.3';
18
18
 
19
19
  /*!
20
20
  * Assertion Error
@@ -405,6 +405,7 @@ module.exports = function (chai, _) {
405
405
  * - but
406
406
  * - does
407
407
  * - still
408
+ * - also
408
409
  *
409
410
  * @name language chains
410
411
  * @namespace BDD
@@ -414,7 +415,7 @@ module.exports = function (chai, _) {
414
415
  [ 'to', 'be', 'been', 'is'
415
416
  , 'and', 'has', 'have', 'with'
416
417
  , 'that', 'which', 'at', 'of'
417
- , 'same', 'but', 'does', 'still' ].forEach(function (chain) {
418
+ , 'same', 'but', 'does', 'still', "also" ].forEach(function (chain) {
418
419
  Assertion.addProperty(chain);
419
420
  });
420
421
 
@@ -1194,19 +1195,25 @@ module.exports = function (chai, _) {
1194
1195
  *
1195
1196
  * expect(null, 'nooo why fail??').to.exist;
1196
1197
  *
1198
+ * The alias `.exists` can be used interchangeably with `.exist`.
1199
+ *
1197
1200
  * @name exist
1201
+ * @alias exists
1198
1202
  * @namespace BDD
1199
1203
  * @api public
1200
1204
  */
1201
1205
 
1202
- Assertion.addProperty('exist', function () {
1206
+ function assertExist () {
1203
1207
  var val = flag(this, 'object');
1204
1208
  this.assert(
1205
1209
  val !== null && val !== undefined
1206
1210
  , 'expected #{this} to exist'
1207
1211
  , 'expected #{this} to not exist'
1208
1212
  );
1209
- });
1213
+ }
1214
+
1215
+ Assertion.addProperty('exist', assertExist);
1216
+ Assertion.addProperty('exists', assertExist);
1210
1217
 
1211
1218
  /**
1212
1219
  * ### .empty
@@ -1606,10 +1613,12 @@ module.exports = function (chai, _) {
1606
1613
  * expect(1).to.be.at.least(2, 'nooo why fail??');
1607
1614
  * expect(1, 'nooo why fail??').to.be.at.least(2);
1608
1615
  *
1609
- * The alias `.gte` can be used interchangeably with `.least`.
1616
+ * The aliases `.gte` and `.greaterThanOrEqual` can be used interchangeably with
1617
+ * `.least`.
1610
1618
  *
1611
1619
  * @name least
1612
1620
  * @alias gte
1621
+ * @alias greaterThanOrEqual
1613
1622
  * @param {Number} n
1614
1623
  * @param {String} msg _optional_
1615
1624
  * @namespace BDD
@@ -1675,6 +1684,7 @@ module.exports = function (chai, _) {
1675
1684
 
1676
1685
  Assertion.addMethod('least', assertLeast);
1677
1686
  Assertion.addMethod('gte', assertLeast);
1687
+ Assertion.addMethod('greaterThanOrEqual', assertLeast);
1678
1688
 
1679
1689
  /**
1680
1690
  * ### .below(n[, msg])
@@ -1812,10 +1822,12 @@ module.exports = function (chai, _) {
1812
1822
  * expect(2).to.be.at.most(1, 'nooo why fail??');
1813
1823
  * expect(2, 'nooo why fail??').to.be.at.most(1);
1814
1824
  *
1815
- * The alias `.lte` can be used interchangeably with `.most`.
1825
+ * The aliases `.lte` and `.lessThanOrEqual` can be used interchangeably with
1826
+ * `.most`.
1816
1827
  *
1817
1828
  * @name most
1818
1829
  * @alias lte
1830
+ * @alias lessThanOrEqual
1819
1831
  * @param {Number} n
1820
1832
  * @param {String} msg _optional_
1821
1833
  * @namespace BDD
@@ -1881,6 +1893,7 @@ module.exports = function (chai, _) {
1881
1893
 
1882
1894
  Assertion.addMethod('most', assertMost);
1883
1895
  Assertion.addMethod('lte', assertMost);
1896
+ Assertion.addMethod('lessThanOrEqual', assertMost);
1884
1897
 
1885
1898
  /**
1886
1899
  * ### .within(start, finish[, msg])
@@ -3521,7 +3534,8 @@ module.exports = function (chai, _) {
3521
3534
  var expected = flag(this, 'object')
3522
3535
  , flagMsg = flag(this, 'message')
3523
3536
  , ssfi = flag(this, 'ssfi')
3524
- , contains = flag(this, 'contains');
3537
+ , contains = flag(this, 'contains')
3538
+ , isDeep = flag(this, 'deep');
3525
3539
  new Assertion(list, flagMsg, ssfi, true).to.be.an('array');
3526
3540
 
3527
3541
  if (contains) {
@@ -3533,13 +3547,23 @@ module.exports = function (chai, _) {
3533
3547
  , expected
3534
3548
  );
3535
3549
  } else {
3536
- this.assert(
3537
- list.indexOf(expected) > -1
3538
- , 'expected #{this} to be one of #{exp}'
3539
- , 'expected #{this} to not be one of #{exp}'
3540
- , list
3541
- , expected
3542
- );
3550
+ if (isDeep) {
3551
+ this.assert(
3552
+ list.some(function(possibility) { return _.eql(expected, possibility) })
3553
+ , 'expected #{this} to deeply equal one of #{exp}'
3554
+ , 'expected #{this} to deeply equal one of #{exp}'
3555
+ , list
3556
+ , expected
3557
+ );
3558
+ } else {
3559
+ this.assert(
3560
+ list.indexOf(expected) > -1
3561
+ , 'expected #{this} to be one of #{exp}'
3562
+ , 'expected #{this} to not be one of #{exp}'
3563
+ , list
3564
+ , expected
3565
+ );
3566
+ }
3543
3567
  }
3544
3568
  }
3545
3569
 
@@ -6462,7 +6486,7 @@ module.exports = function (chai, util) {
6462
6486
  * Asserts that `set1` and `set2` have the same members in the same order.
6463
6487
  * Uses a deep equality check.
6464
6488
  *
6465
- * assert.sameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { c: 3 } ], 'same deep ordered members');
6489
+ * assert.sameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { c: 3 } ], 'same deep ordered members');
6466
6490
  *
6467
6491
  * @name sameDeepOrderedMembers
6468
6492
  * @param {Array} set1
@@ -6483,8 +6507,8 @@ module.exports = function (chai, util) {
6483
6507
  * Asserts that `set1` and `set2` don't have the same members in the same
6484
6508
  * order. Uses a deep equality check.
6485
6509
  *
6486
- * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { z: 5 } ], 'not same deep ordered members');
6487
- * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 }, { c: 3 } ], 'not same deep ordered members');
6510
+ * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { z: 5 } ], 'not same deep ordered members');
6511
+ * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 }, { c: 3 } ], 'not same deep ordered members');
6488
6512
  *
6489
6513
  * @name notSameDeepOrderedMembers
6490
6514
  * @param {Array} set1
@@ -6904,7 +6928,7 @@ module.exports = function (chai, util) {
6904
6928
  }
6905
6929
 
6906
6930
  /**
6907
- * ### .increasesButNotBy(function, object, property, [message])
6931
+ * ### .increasesButNotBy(function, object, property, delta, [message])
6908
6932
  *
6909
6933
  * Asserts that a function does not increase a numeric object property or function's return value by an amount (delta).
6910
6934
  *
@@ -7034,7 +7058,7 @@ module.exports = function (chai, util) {
7034
7058
  * var fn = function() { obj.val = 5 };
7035
7059
  * assert.doesNotDecreaseBy(fn, obj, 'val', 1);
7036
7060
  *
7037
- * @name doesNotDecrease
7061
+ * @name doesNotDecreaseBy
7038
7062
  * @param {Function} modifier function
7039
7063
  * @param {Object} object or getter function
7040
7064
  * @param {String} property name _optional_
@@ -8722,6 +8746,9 @@ function formatPrimitive(ctx, value) {
8722
8746
 
8723
8747
  case 'symbol':
8724
8748
  return ctx.stylize(value.toString(), 'symbol');
8749
+
8750
+ case 'bigint':
8751
+ return ctx.stylize(value.toString() + 'n', 'bigint');
8725
8752
  }
8726
8753
  // For some reason typeof null is "object", so special case here.
8727
8754
  if (value === null) {
@@ -10344,13 +10371,20 @@ function parsePath(path) {
10344
10371
  var str = path.replace(/([^\\])\[/g, '$1.[');
10345
10372
  var parts = str.match(/(\\\.|[^.]+?)+/g);
10346
10373
  return parts.map(function mapMatches(value) {
10374
+ if (
10375
+ value === 'constructor' ||
10376
+ value === '__proto__' ||
10377
+ value === 'prototype'
10378
+ ) {
10379
+ return {};
10380
+ }
10347
10381
  var regexp = /^\[(\d+)\]$/;
10348
10382
  var mArr = regexp.exec(value);
10349
10383
  var parsed = null;
10350
10384
  if (mArr) {
10351
10385
  parsed = { i: parseFloat(mArr[1]) };
10352
10386
  } else {
10353
- parsed = { p: value.replace(/\\([.\[\]])/g, '$1') };
10387
+ parsed = { p: value.replace(/\\([.[\]])/g, '$1') };
10354
10388
  }
10355
10389
 
10356
10390
  return parsed;
@@ -10375,7 +10409,7 @@ function parsePath(path) {
10375
10409
  function internalGetPathValue(obj, parsed, pathDepth) {
10376
10410
  var temporaryValue = obj;
10377
10411
  var res = null;
10378
- pathDepth = (typeof pathDepth === 'undefined' ? parsed.length : pathDepth);
10412
+ pathDepth = typeof pathDepth === 'undefined' ? parsed.length : pathDepth;
10379
10413
 
10380
10414
  for (var i = 0; i < pathDepth; i++) {
10381
10415
  var part = parsed[i];
@@ -10386,7 +10420,7 @@ function internalGetPathValue(obj, parsed, pathDepth) {
10386
10420
  temporaryValue = temporaryValue[part.p];
10387
10421
  }
10388
10422
 
10389
- if (i === (pathDepth - 1)) {
10423
+ if (i === pathDepth - 1) {
10390
10424
  res = temporaryValue;
10391
10425
  }
10392
10426
  }
@@ -10420,7 +10454,7 @@ function internalSetPathValue(obj, val, parsed) {
10420
10454
  part = parsed[i];
10421
10455
 
10422
10456
  // If it's the last part of the path, we set the 'propName' value with the property name
10423
- if (i === (pathDepth - 1)) {
10457
+ if (i === pathDepth - 1) {
10424
10458
  propName = typeof part.p === 'undefined' ? part.i : part.p;
10425
10459
  // Now we set the property with the name held by 'propName' on object with the desired val
10426
10460
  tempObj[propName] = val;
@@ -10467,7 +10501,10 @@ function getPathInfo(obj, path) {
10467
10501
  var parsed = parsePath(path);
10468
10502
  var last = parsed[parsed.length - 1];
10469
10503
  var info = {
10470
- parent: parsed.length > 1 ? internalGetPathValue(obj, parsed, parsed.length - 1) : obj,
10504
+ parent:
10505
+ parsed.length > 1 ?
10506
+ internalGetPathValue(obj, parsed, parsed.length - 1) :
10507
+ obj,
10471
10508
  name: last.p || last.i,
10472
10509
  value: internalGetPathValue(obj, parsed),
10473
10510
  };
package/index.mjs CHANGED
@@ -2,6 +2,7 @@ import chai from './index.js';
2
2
 
3
3
  export const expect = chai.expect;
4
4
  export const version = chai.version;
5
+ export const Assertion = chai.Assertion;
5
6
  export const AssertionError = chai.AssertionError;
6
7
  export const util = chai.util;
7
8
  export const config = chai.config;
@@ -34,6 +34,7 @@ module.exports = function (chai, _) {
34
34
  * - but
35
35
  * - does
36
36
  * - still
37
+ * - also
37
38
  *
38
39
  * @name language chains
39
40
  * @namespace BDD
@@ -43,7 +44,7 @@ module.exports = function (chai, _) {
43
44
  [ 'to', 'be', 'been', 'is'
44
45
  , 'and', 'has', 'have', 'with'
45
46
  , 'that', 'which', 'at', 'of'
46
- , 'same', 'but', 'does', 'still' ].forEach(function (chain) {
47
+ , 'same', 'but', 'does', 'still', "also" ].forEach(function (chain) {
47
48
  Assertion.addProperty(chain);
48
49
  });
49
50
 
@@ -823,19 +824,25 @@ module.exports = function (chai, _) {
823
824
  *
824
825
  * expect(null, 'nooo why fail??').to.exist;
825
826
  *
827
+ * The alias `.exists` can be used interchangeably with `.exist`.
828
+ *
826
829
  * @name exist
830
+ * @alias exists
827
831
  * @namespace BDD
828
832
  * @api public
829
833
  */
830
834
 
831
- Assertion.addProperty('exist', function () {
835
+ function assertExist () {
832
836
  var val = flag(this, 'object');
833
837
  this.assert(
834
838
  val !== null && val !== undefined
835
839
  , 'expected #{this} to exist'
836
840
  , 'expected #{this} to not exist'
837
841
  );
838
- });
842
+ }
843
+
844
+ Assertion.addProperty('exist', assertExist);
845
+ Assertion.addProperty('exists', assertExist);
839
846
 
840
847
  /**
841
848
  * ### .empty
@@ -1235,10 +1242,12 @@ module.exports = function (chai, _) {
1235
1242
  * expect(1).to.be.at.least(2, 'nooo why fail??');
1236
1243
  * expect(1, 'nooo why fail??').to.be.at.least(2);
1237
1244
  *
1238
- * The alias `.gte` can be used interchangeably with `.least`.
1245
+ * The aliases `.gte` and `.greaterThanOrEqual` can be used interchangeably with
1246
+ * `.least`.
1239
1247
  *
1240
1248
  * @name least
1241
1249
  * @alias gte
1250
+ * @alias greaterThanOrEqual
1242
1251
  * @param {Number} n
1243
1252
  * @param {String} msg _optional_
1244
1253
  * @namespace BDD
@@ -1304,6 +1313,7 @@ module.exports = function (chai, _) {
1304
1313
 
1305
1314
  Assertion.addMethod('least', assertLeast);
1306
1315
  Assertion.addMethod('gte', assertLeast);
1316
+ Assertion.addMethod('greaterThanOrEqual', assertLeast);
1307
1317
 
1308
1318
  /**
1309
1319
  * ### .below(n[, msg])
@@ -1441,10 +1451,12 @@ module.exports = function (chai, _) {
1441
1451
  * expect(2).to.be.at.most(1, 'nooo why fail??');
1442
1452
  * expect(2, 'nooo why fail??').to.be.at.most(1);
1443
1453
  *
1444
- * The alias `.lte` can be used interchangeably with `.most`.
1454
+ * The aliases `.lte` and `.lessThanOrEqual` can be used interchangeably with
1455
+ * `.most`.
1445
1456
  *
1446
1457
  * @name most
1447
1458
  * @alias lte
1459
+ * @alias lessThanOrEqual
1448
1460
  * @param {Number} n
1449
1461
  * @param {String} msg _optional_
1450
1462
  * @namespace BDD
@@ -1510,6 +1522,7 @@ module.exports = function (chai, _) {
1510
1522
 
1511
1523
  Assertion.addMethod('most', assertMost);
1512
1524
  Assertion.addMethod('lte', assertMost);
1525
+ Assertion.addMethod('lessThanOrEqual', assertMost);
1513
1526
 
1514
1527
  /**
1515
1528
  * ### .within(start, finish[, msg])
@@ -3150,7 +3163,8 @@ module.exports = function (chai, _) {
3150
3163
  var expected = flag(this, 'object')
3151
3164
  , flagMsg = flag(this, 'message')
3152
3165
  , ssfi = flag(this, 'ssfi')
3153
- , contains = flag(this, 'contains');
3166
+ , contains = flag(this, 'contains')
3167
+ , isDeep = flag(this, 'deep');
3154
3168
  new Assertion(list, flagMsg, ssfi, true).to.be.an('array');
3155
3169
 
3156
3170
  if (contains) {
@@ -3162,13 +3176,23 @@ module.exports = function (chai, _) {
3162
3176
  , expected
3163
3177
  );
3164
3178
  } else {
3165
- this.assert(
3166
- list.indexOf(expected) > -1
3167
- , 'expected #{this} to be one of #{exp}'
3168
- , 'expected #{this} to not be one of #{exp}'
3169
- , list
3170
- , expected
3171
- );
3179
+ if (isDeep) {
3180
+ this.assert(
3181
+ list.some(function(possibility) { return _.eql(expected, possibility) })
3182
+ , 'expected #{this} to deeply equal one of #{exp}'
3183
+ , 'expected #{this} to deeply equal one of #{exp}'
3184
+ , list
3185
+ , expected
3186
+ );
3187
+ } else {
3188
+ this.assert(
3189
+ list.indexOf(expected) > -1
3190
+ , 'expected #{this} to be one of #{exp}'
3191
+ , 'expected #{this} to not be one of #{exp}'
3192
+ , list
3193
+ , expected
3194
+ );
3195
+ }
3172
3196
  }
3173
3197
  }
3174
3198
 
@@ -2260,7 +2260,7 @@ module.exports = function (chai, util) {
2260
2260
  * Asserts that `set1` and `set2` have the same members in the same order.
2261
2261
  * Uses a deep equality check.
2262
2262
  *
2263
- * assert.sameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { c: 3 } ], 'same deep ordered members');
2263
+ * assert.sameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { c: 3 } ], 'same deep ordered members');
2264
2264
  *
2265
2265
  * @name sameDeepOrderedMembers
2266
2266
  * @param {Array} set1
@@ -2281,8 +2281,8 @@ module.exports = function (chai, util) {
2281
2281
  * Asserts that `set1` and `set2` don't have the same members in the same
2282
2282
  * order. Uses a deep equality check.
2283
2283
  *
2284
- * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { z: 5 } ], 'not same deep ordered members');
2285
- * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 }, { c: 3 } ], 'not same deep ordered members');
2284
+ * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { z: 5 } ], 'not same deep ordered members');
2285
+ * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 }, { c: 3 } ], 'not same deep ordered members');
2286
2286
  *
2287
2287
  * @name notSameDeepOrderedMembers
2288
2288
  * @param {Array} set1
@@ -2702,7 +2702,7 @@ module.exports = function (chai, util) {
2702
2702
  }
2703
2703
 
2704
2704
  /**
2705
- * ### .increasesButNotBy(function, object, property, [message])
2705
+ * ### .increasesButNotBy(function, object, property, delta, [message])
2706
2706
  *
2707
2707
  * Asserts that a function does not increase a numeric object property or function's return value by an amount (delta).
2708
2708
  *
@@ -2832,7 +2832,7 @@ module.exports = function (chai, util) {
2832
2832
  * var fn = function() { obj.val = 5 };
2833
2833
  * assert.doesNotDecreaseBy(fn, obj, 'val', 1);
2834
2834
  *
2835
- * @name doesNotDecrease
2835
+ * @name doesNotDecreaseBy
2836
2836
  * @param {Function} modifier function
2837
2837
  * @param {Object} object or getter function
2838
2838
  * @param {String} property name _optional_
@@ -218,6 +218,9 @@ function formatPrimitive(ctx, value) {
218
218
 
219
219
  case 'symbol':
220
220
  return ctx.stylize(value.toString(), 'symbol');
221
+
222
+ case 'bigint':
223
+ return ctx.stylize(value.toString() + 'n', 'bigint');
221
224
  }
222
225
  // For some reason typeof null is "object", so special case here.
223
226
  if (value === null) {
package/lib/chai.js CHANGED
@@ -10,7 +10,7 @@ var used = [];
10
10
  * Chai version
11
11
  */
12
12
 
13
- exports.version = '4.3.0';
13
+ exports.version = '4.3.3';
14
14
 
15
15
  /*!
16
16
  * Assertion Error
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "Veselin Todorov <hi@vesln.com>",
18
18
  "John Firebaugh <john.firebaugh@gmail.com>"
19
19
  ],
20
- "version": "4.3.0",
20
+ "version": "4.3.4",
21
21
  "repository": {
22
22
  "type": "git",
23
23
  "url": "https://github.com/chaijs/chai"
@@ -37,14 +37,14 @@
37
37
  "test": "make test"
38
38
  },
39
39
  "engines": {
40
- "node": ">=8"
40
+ "node": ">=4"
41
41
  },
42
42
  "dependencies": {
43
43
  "assertion-error": "^1.1.0",
44
44
  "check-error": "^1.0.2",
45
45
  "deep-eql": "^3.0.1",
46
46
  "get-func-name": "^2.0.0",
47
- "pathval": "^1.1.0",
47
+ "pathval": "^1.1.1",
48
48
  "type-detect": "^4.0.5"
49
49
  },
50
50
  "devDependencies": {
@@ -52,10 +52,10 @@
52
52
  "bump-cli": "^1.1.3",
53
53
  "codecov": "^3.0.0",
54
54
  "istanbul": "^0.4.3",
55
- "karma": "^2.0.0",
55
+ "karma": "^6.1.1",
56
56
  "karma-chrome-launcher": "^2.2.0",
57
57
  "karma-firefox-launcher": "^1.0.0",
58
- "karma-mocha": "^1.0.1",
58
+ "karma-mocha": "^2.0.1",
59
59
  "karma-sauce-launcher": "^1.2.0",
60
60
  "mocha": "^7.1.2"
61
61
  }
package/sauce.browsers.js CHANGED
@@ -32,11 +32,15 @@ exports['SL_IE'] = {
32
32
  , browserName: 'internet explorer'
33
33
  };
34
34
 
35
+ /*!
36
+ * TODO: fails because of Uint8Array support
37
+ *
35
38
  exports['SL_IE_Old'] = {
36
39
  base: 'SauceLabs'
37
40
  , browserName: 'internet explorer'
38
41
  , version: 10
39
42
  };
43
+ */
40
44
 
41
45
  exports['SL_Edge'] = {
42
46
  base: 'SauceLabs'