chai 5.0.3 → 5.1.1

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 (38) hide show
  1. package/README.md +3 -3
  2. package/chai.js +94 -220
  3. package/eslint.config.js +12 -0
  4. package/lib/chai/assertion.js +30 -31
  5. package/lib/chai/config.js +18 -24
  6. package/lib/chai/core/assertions.js +253 -223
  7. package/lib/chai/interface/assert.js +574 -670
  8. package/lib/chai/interface/expect.js +12 -7
  9. package/lib/chai/interface/should.js +43 -40
  10. package/lib/chai/utils/addChainableMethod.js +6 -11
  11. package/lib/chai/utils/addLengthGuard.js +3 -3
  12. package/lib/chai/utils/addMethod.js +5 -6
  13. package/lib/chai/utils/addProperty.js +5 -6
  14. package/lib/chai/utils/compareByInspect.js +4 -9
  15. package/lib/chai/utils/expectTypes.js +7 -8
  16. package/lib/chai/utils/flag.js +5 -5
  17. package/lib/chai/utils/getActual.js +3 -3
  18. package/lib/chai/utils/getEnumerableProperties.js +2 -3
  19. package/lib/chai/utils/getMessage.js +4 -8
  20. package/lib/chai/utils/getOperator.js +8 -4
  21. package/lib/chai/utils/getOwnEnumerableProperties.js +2 -7
  22. package/lib/chai/utils/getOwnEnumerablePropertySymbols.js +2 -3
  23. package/lib/chai/utils/getProperties.js +5 -3
  24. package/lib/chai/utils/index.js +42 -109
  25. package/lib/chai/utils/inspect.js +5 -4
  26. package/lib/chai/utils/isNaN.js +3 -3
  27. package/lib/chai/utils/isProxyEnabled.js +1 -1
  28. package/lib/chai/utils/objDisplay.js +2 -7
  29. package/lib/chai/utils/overwriteChainableMethod.js +7 -8
  30. package/lib/chai/utils/overwriteMethod.js +10 -11
  31. package/lib/chai/utils/overwriteProperty.js +10 -12
  32. package/lib/chai/utils/proxify.js +9 -9
  33. package/lib/chai/utils/test.js +3 -7
  34. package/lib/chai/utils/transferFlags.js +4 -6
  35. package/lib/chai/utils/type-detect.js +4 -0
  36. package/lib/chai.js +9 -31
  37. package/package.json +6 -3
  38. package/web-test-runner.config.js +4 -1
package/README.md CHANGED
@@ -98,9 +98,9 @@ import { expect, use } from 'chai'; // Creates local variables `expect` and `us
98
98
  ### Usage with Mocha
99
99
 
100
100
  ```bash
101
- mocha spec.js -r chai/register-assert # Using Assert style
102
- mocha spec.js -r chai/register-expect # Using Expect style
103
- mocha spec.js -r chai/register-should # Using Should style
101
+ mocha spec.js --require chai/register-assert.js # Using Assert style
102
+ mocha spec.js --require chai/register-expect.js # Using Expect style
103
+ mocha spec.js --require chai/register-should.js # Using Should style
104
104
  ```
105
105
 
106
106
  [Read more about these styles in our docs](http://chaijs.com/guide/styles/).
package/chai.js CHANGED
@@ -38,6 +38,7 @@ __export(utils_exports, {
38
38
  inspect: () => inspect2,
39
39
  isNaN: () => isNaN2,
40
40
  isProxyEnabled: () => isProxyEnabled,
41
+ isRegExp: () => isRegExp2,
41
42
  objDisplay: () => objDisplay,
42
43
  overwriteChainableMethod: () => overwriteChainableMethod,
43
44
  overwriteMethod: () => overwriteMethod,
@@ -57,14 +58,22 @@ __export(check_error_exports, {
57
58
  getConstructorName: () => getConstructorName,
58
59
  getMessage: () => getMessage
59
60
  });
61
+ function isErrorInstance(obj) {
62
+ return obj instanceof Error || Object.prototype.toString.call(obj) === "[object Error]";
63
+ }
64
+ __name(isErrorInstance, "isErrorInstance");
65
+ function isRegExp(obj) {
66
+ return Object.prototype.toString.call(obj) === "[object RegExp]";
67
+ }
68
+ __name(isRegExp, "isRegExp");
60
69
  function compatibleInstance(thrown, errorLike) {
61
- return errorLike instanceof Error && thrown === errorLike;
70
+ return isErrorInstance(errorLike) && thrown === errorLike;
62
71
  }
63
72
  __name(compatibleInstance, "compatibleInstance");
64
73
  function compatibleConstructor(thrown, errorLike) {
65
- if (errorLike instanceof Error) {
74
+ if (isErrorInstance(errorLike)) {
66
75
  return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor;
67
- } else if (errorLike.prototype instanceof Error || errorLike === Error) {
76
+ } else if ((typeof errorLike === "object" || typeof errorLike === "function") && errorLike.prototype) {
68
77
  return thrown.constructor === errorLike || thrown instanceof errorLike;
69
78
  }
70
79
  return false;
@@ -72,7 +81,7 @@ function compatibleConstructor(thrown, errorLike) {
72
81
  __name(compatibleConstructor, "compatibleConstructor");
73
82
  function compatibleMessage(thrown, errMatcher) {
74
83
  const comparisonString = typeof thrown === "string" ? thrown : thrown.message;
75
- if (errMatcher instanceof RegExp) {
84
+ if (isRegExp(errMatcher)) {
76
85
  return errMatcher.test(comparisonString);
77
86
  } else if (typeof errMatcher === "string") {
78
87
  return comparisonString.indexOf(errMatcher) !== -1;
@@ -82,7 +91,7 @@ function compatibleMessage(thrown, errMatcher) {
82
91
  __name(compatibleMessage, "compatibleMessage");
83
92
  function getConstructorName(errorLike) {
84
93
  let constructorName = errorLike;
85
- if (errorLike instanceof Error) {
94
+ if (isErrorInstance(errorLike)) {
86
95
  constructorName = errorLike.constructor.name;
87
96
  } else if (typeof errorLike === "function") {
88
97
  constructorName = errorLike.name;
@@ -805,8 +814,8 @@ var config = {
805
814
  *
806
815
  * chai.config.includeStack = true; // enable stack on error
807
816
  *
808
- * @param {Boolean}
809
- * @api public
817
+ * @param {boolean}
818
+ * @public
810
819
  */
811
820
  includeStack: false,
812
821
  /**
@@ -818,8 +827,8 @@ var config = {
818
827
  * will be true when the assertion has requested a diff
819
828
  * be shown.
820
829
  *
821
- * @param {Boolean}
822
- * @api public
830
+ * @param {boolean}
831
+ * @public
823
832
  */
824
833
  showDiff: true,
825
834
  /**
@@ -838,8 +847,8 @@ var config = {
838
847
  *
839
848
  * chai.config.truncateThreshold = 0; // disable truncating
840
849
  *
841
- * @param {Number}
842
- * @api public
850
+ * @param {number}
851
+ * @public
843
852
  */
844
853
  truncateThreshold: 40,
845
854
  /**
@@ -856,8 +865,8 @@ var config = {
856
865
  * This feature is automatically disabled regardless of this config value
857
866
  * in environments that don't support proxies.
858
867
  *
859
- * @param {Boolean}
860
- * @api public
868
+ * @param {boolean}
869
+ * @public
861
870
  */
862
871
  useProxy: true,
863
872
  /**
@@ -875,7 +884,7 @@ var config = {
875
884
  * chai.config.proxyExcludedKeys = ['then', 'inspect'];
876
885
  *
877
886
  * @param {Array}
878
- * @api public
887
+ * @public
879
888
  */
880
889
  proxyExcludedKeys: ["then", "catch", "inspect", "toJSON"],
881
890
  /**
@@ -887,18 +896,18 @@ var config = {
887
896
  *
888
897
  * // use a custom comparator
889
898
  * chai.config.deepEqual = (expected, actual) => {
890
- * return chai.util.eql(expected, actual, {
891
- * comparator: (expected, actual) => {
892
- * // for non number comparison, use the default behavior
893
- * if(typeof expected !== 'number') return null;
894
- * // allow a difference of 10 between compared numbers
895
- * return typeof actual === 'number' && Math.abs(actual - expected) < 10
896
- * }
897
- * })
899
+ * return chai.util.eql(expected, actual, {
900
+ * comparator: (expected, actual) => {
901
+ * // for non number comparison, use the default behavior
902
+ * if(typeof expected !== 'number') return null;
903
+ * // allow a difference of 10 between compared numbers
904
+ * return typeof actual === 'number' && Math.abs(actual - expected) < 10
905
+ * }
906
+ * })
898
907
  * };
899
908
  *
900
909
  * @param {Function}
901
- * @api public
910
+ * @public
902
911
  */
903
912
  deepEqual: null
904
913
  };
@@ -1809,6 +1818,10 @@ function getName(fn) {
1809
1818
  return fn.name;
1810
1819
  }
1811
1820
  __name(getName, "getName");
1821
+ function isRegExp2(obj) {
1822
+ return Object.prototype.toString.call(obj) === "[object RegExp]";
1823
+ }
1824
+ __name(isRegExp2, "isRegExp");
1812
1825
 
1813
1826
  // lib/chai/core/assertions.js
1814
1827
  var { flag: flag2 } = utils_exports;
@@ -2659,14 +2672,16 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
2659
2672
  flag2(this, "message", msg);
2660
2673
  var obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), negate = flag2(this, "negate") || false;
2661
2674
  new Assertion(obj, flagMsg, ssfi, true).is.a("function");
2662
- if (errorLike instanceof RegExp || typeof errorLike === "string") {
2675
+ if (isRegExp2(errorLike) || typeof errorLike === "string") {
2663
2676
  errMsgMatcher = errorLike;
2664
2677
  errorLike = null;
2665
2678
  }
2666
- var caughtErr;
2679
+ let caughtErr;
2680
+ let errorWasThrown = false;
2667
2681
  try {
2668
2682
  obj();
2669
2683
  } catch (err) {
2684
+ errorWasThrown = true;
2670
2685
  caughtErr = err;
2671
2686
  }
2672
2687
  var everyArgIsUndefined = errorLike === void 0 && errMsgMatcher === void 0;
@@ -2680,12 +2695,23 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
2680
2695
  } else if (errorLike) {
2681
2696
  errorLikeString = check_error_exports.getConstructorName(errorLike);
2682
2697
  }
2698
+ let actual = caughtErr;
2699
+ if (caughtErr instanceof Error) {
2700
+ actual = caughtErr.toString();
2701
+ } else if (typeof caughtErr === "string") {
2702
+ actual = caughtErr;
2703
+ } else if (caughtErr && (typeof caughtErr === "object" || typeof caughtErr === "function")) {
2704
+ try {
2705
+ actual = check_error_exports.getConstructorName(caughtErr);
2706
+ } catch (_err) {
2707
+ }
2708
+ }
2683
2709
  this.assert(
2684
- caughtErr,
2710
+ errorWasThrown,
2685
2711
  "expected #{this} to throw " + errorLikeString,
2686
2712
  "expected #{this} to not throw an error but #{act} was thrown",
2687
2713
  errorLike && errorLike.toString(),
2688
- caughtErr instanceof Error ? caughtErr.toString() : typeof caughtErr === "string" ? caughtErr : caughtErr && check_error_exports.getConstructorName(caughtErr)
2714
+ actual
2689
2715
  );
2690
2716
  }
2691
2717
  if (errorLike && caughtErr) {
@@ -2722,7 +2748,7 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
2722
2748
  }
2723
2749
  if (caughtErr && errMsgMatcher !== void 0 && errMsgMatcher !== null) {
2724
2750
  var placeholder = "including";
2725
- if (errMsgMatcher instanceof RegExp) {
2751
+ if (isRegExp2(errMsgMatcher)) {
2726
2752
  placeholder = "matching";
2727
2753
  }
2728
2754
  var isCompatibleMessage = check_error_exports.compatibleMessage(caughtErr, errMsgMatcher);
@@ -2810,7 +2836,9 @@ function closeTo(expected, delta, msg) {
2810
2836
  __name(closeTo, "closeTo");
2811
2837
  Assertion.addMethod("closeTo", closeTo);
2812
2838
  Assertion.addMethod("approximately", closeTo);
2813
- function isSubsetOf(subset, superset, cmp, contains, ordered) {
2839
+ function isSubsetOf(_subset, _superset, cmp, contains, ordered) {
2840
+ let superset = Array.from(_superset);
2841
+ let subset = Array.from(_subset);
2814
2842
  if (!contains) {
2815
2843
  if (subset.length !== superset.length)
2816
2844
  return false;
@@ -2841,8 +2869,8 @@ Assertion.addMethod("members", function(subset, msg) {
2841
2869
  if (msg)
2842
2870
  flag2(this, "message", msg);
2843
2871
  var obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
2844
- new Assertion(obj, flagMsg, ssfi, true).to.be.an("array");
2845
- new Assertion(subset, flagMsg, ssfi, true).to.be.an("array");
2872
+ new Assertion(obj, flagMsg, ssfi, true).to.be.iterable;
2873
+ new Assertion(subset, flagMsg, ssfi, true).to.be.iterable;
2846
2874
  var contains = flag2(this, "contains");
2847
2875
  var ordered = flag2(this, "ordered");
2848
2876
  var subject, failMsg, failNegateMsg;
@@ -2865,6 +2893,17 @@ Assertion.addMethod("members", function(subset, msg) {
2865
2893
  true
2866
2894
  );
2867
2895
  });
2896
+ Assertion.addProperty("iterable", function(msg) {
2897
+ if (msg)
2898
+ flag2(this, "message", msg);
2899
+ var obj = flag2(this, "object");
2900
+ this.assert(
2901
+ obj != void 0 && obj[Symbol.iterator],
2902
+ "expected #{this} to be an iterable",
2903
+ "expected #{this} to not be an iterable",
2904
+ obj
2905
+ );
2906
+ });
2868
2907
  function oneOf(list, msg) {
2869
2908
  if (msg)
2870
2909
  flag2(this, "message", msg);
@@ -3113,8 +3152,8 @@ function loadShould() {
3113
3152
  operator
3114
3153
  }, should2.fail);
3115
3154
  };
3116
- should2.equal = function(val1, val2, msg) {
3117
- new Assertion(val1, msg).to.equal(val2);
3155
+ should2.equal = function(actual, expected, message) {
3156
+ new Assertion(actual, message).to.equal(expected);
3118
3157
  };
3119
3158
  should2.Throw = function(fn, errt, errs, msg) {
3120
3159
  new Assertion(fn, msg).to.Throw(errt, errs);
@@ -3123,8 +3162,8 @@ function loadShould() {
3123
3162
  new Assertion(val, msg).to.exist;
3124
3163
  };
3125
3164
  should2.not = {};
3126
- should2.not.equal = function(val1, val2, msg) {
3127
- new Assertion(val1, msg).to.not.equal(val2);
3165
+ should2.not.equal = function(actual, expected, msg) {
3166
+ new Assertion(actual, msg).to.not.equal(expected);
3128
3167
  };
3129
3168
  should2.not.Throw = function(fn, errt, errs, msg) {
3130
3169
  new Assertion(fn, msg).to.not.Throw(errt, errs);
@@ -3235,8 +3274,8 @@ assert.isNotNull = function(val, msg) {
3235
3274
  assert.isNaN = function(val, msg) {
3236
3275
  new Assertion(val, msg, assert.isNaN, true).to.be.NaN;
3237
3276
  };
3238
- assert.isNotNaN = function(val, msg) {
3239
- new Assertion(val, msg, assert.isNotNaN, true).not.to.be.NaN;
3277
+ assert.isNotNaN = function(value, message) {
3278
+ new Assertion(value, message, assert.isNotNaN, true).not.to.be.NaN;
3240
3279
  };
3241
3280
  assert.exists = function(val, msg) {
3242
3281
  new Assertion(val, msg, assert.exists, true).to.exist;
@@ -3250,11 +3289,11 @@ assert.isUndefined = function(val, msg) {
3250
3289
  assert.isDefined = function(val, msg) {
3251
3290
  new Assertion(val, msg, assert.isDefined, true).to.not.equal(void 0);
3252
3291
  };
3253
- assert.isCallable = function(val, msg) {
3254
- new Assertion(val, msg, assert.isCallable, true).is.callable;
3292
+ assert.isCallable = function(value, message) {
3293
+ new Assertion(value, message, assert.isCallable, true).is.callable;
3255
3294
  };
3256
- assert.isNotCallable = function(val, msg) {
3257
- new Assertion(val, msg, assert.isNotCallable, true).is.not.callable;
3295
+ assert.isNotCallable = function(value, message) {
3296
+ new Assertion(value, message, assert.isNotCallable, true).is.not.callable;
3258
3297
  };
3259
3298
  assert.isObject = function(val, msg) {
3260
3299
  new Assertion(val, msg, assert.isObject, true).to.be.a("object");
@@ -3292,8 +3331,8 @@ assert.isNotBoolean = function(val, msg) {
3292
3331
  assert.typeOf = function(val, type3, msg) {
3293
3332
  new Assertion(val, msg, assert.typeOf, true).to.be.a(type3);
3294
3333
  };
3295
- assert.notTypeOf = function(val, type3, msg) {
3296
- new Assertion(val, msg, assert.notTypeOf, true).to.not.be.a(type3);
3334
+ assert.notTypeOf = function(value, type3, message) {
3335
+ new Assertion(value, message, assert.notTypeOf, true).to.not.be.a(type3);
3297
3336
  };
3298
3337
  assert.instanceOf = function(val, type3, msg) {
3299
3338
  new Assertion(val, msg, assert.instanceOf, true).to.be.instanceOf(type3);
@@ -3438,12 +3477,12 @@ assert.throws = function(fn, errorLike, errMsgMatcher, msg) {
3438
3477
  var assertErr = new Assertion(fn, msg, assert.throws, true).to.throw(errorLike, errMsgMatcher);
3439
3478
  return flag(assertErr, "object");
3440
3479
  };
3441
- assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, msg) {
3480
+ assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, message) {
3442
3481
  if ("string" === typeof errorLike || errorLike instanceof RegExp) {
3443
3482
  errMsgMatcher = errorLike;
3444
3483
  errorLike = null;
3445
3484
  }
3446
- new Assertion(fn, msg, assert.doesNotThrow, true).to.not.throw(errorLike, errMsgMatcher);
3485
+ new Assertion(fn, message, assert.doesNotThrow, true).to.not.throw(errorLike, errMsgMatcher);
3447
3486
  };
3448
3487
  assert.operator = function(val, operator, val2, msg) {
3449
3488
  var ok;
@@ -3544,6 +3583,16 @@ assert.notIncludeDeepOrderedMembers = function(superset, subset, msg) {
3544
3583
  assert.oneOf = function(inList, list, msg) {
3545
3584
  new Assertion(inList, msg, assert.oneOf, true).to.be.oneOf(list);
3546
3585
  };
3586
+ assert.isIterable = function(obj, msg) {
3587
+ if (obj == void 0 || !obj[Symbol.iterator]) {
3588
+ msg = msg ? `${msg} expected ${inspect2(obj)} to be an iterable` : `expected ${inspect2(obj)} to be an iterable`;
3589
+ throw new AssertionError(
3590
+ msg,
3591
+ void 0,
3592
+ assert.isIterable
3593
+ );
3594
+ }
3595
+ };
3547
3596
  assert.changes = function(fn, obj, prop, msg) {
3548
3597
  if (arguments.length === 3 && typeof obj === "function") {
3549
3598
  msg = prop;
@@ -3737,9 +3786,6 @@ export {
3737
3786
  * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
3738
3787
  * MIT Licensed
3739
3788
  */
3740
- /*!
3741
- * Module dependencies
3742
- */
3743
3789
  /*!
3744
3790
  * Chai - expectTypes utility
3745
3791
  * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
@@ -3766,52 +3812,6 @@ export {
3766
3812
  * Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
3767
3813
  * MIT Licensed
3768
3814
  */
3769
- /*!
3770
- * Assertion Constructor
3771
- *
3772
- * Creates object for chaining.
3773
- *
3774
- * `Assertion` objects contain metadata in the form of flags. Three flags can
3775
- * be assigned during instantiation by passing arguments to this constructor:
3776
- *
3777
- * - `object`: This flag contains the target of the assertion. For example, in
3778
- * the assertion `expect(numKittens).to.equal(7);`, the `object` flag will
3779
- * contain `numKittens` so that the `equal` assertion can reference it when
3780
- * needed.
3781
- *
3782
- * - `message`: This flag contains an optional custom error message to be
3783
- * prepended to the error message that's generated by the assertion when it
3784
- * fails.
3785
- *
3786
- * - `ssfi`: This flag stands for "start stack function indicator". It
3787
- * contains a function reference that serves as the starting point for
3788
- * removing frames from the stack trace of the error that's created by the
3789
- * assertion when it fails. The goal is to provide a cleaner stack trace to
3790
- * end users by removing Chai's internal functions. Note that it only works
3791
- * in environments that support `Error.captureStackTrace`, and only when
3792
- * `Chai.config.includeStack` hasn't been set to `false`.
3793
- *
3794
- * - `lockSsfi`: This flag controls whether or not the given `ssfi` flag
3795
- * should retain its current value, even as assertions are chained off of
3796
- * this object. This is usually set to `true` when creating a new assertion
3797
- * from within another assertion. It's also temporarily set to `true` before
3798
- * an overwritten assertion gets called by the overwriting assertion.
3799
- *
3800
- * - `eql`: This flag contains the deepEqual function to be used by the assertion.
3801
- *
3802
- * @param {Mixed} obj target of the assertion
3803
- * @param {String} msg (optional) custom error message
3804
- * @param {Function} ssfi (optional) starting point for removing stack frames
3805
- * @param {Boolean} lockSsfi (optional) whether or not the ssfi flag is locked
3806
- * @api private
3807
- */
3808
- /*!
3809
- * ### ._obj
3810
- *
3811
- * Quick reference to stored `actual` value for plugin developers.
3812
- *
3813
- * @api private
3814
- */
3815
3815
  /*!
3816
3816
  * Chai - isProxyEnabled helper
3817
3817
  * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
@@ -3857,9 +3857,6 @@ export {
3857
3857
  * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
3858
3858
  * MIT Licensed
3859
3859
  */
3860
- /*!
3861
- * Module variables
3862
- */
3863
3860
  /*!
3864
3861
  * Chai - overwriteChainableMethod utility
3865
3862
  * Copyright(c) 2012-2014 Jake Luer <jake@alogicalparadox.com>
@@ -3890,134 +3887,11 @@ export {
3890
3887
  * Copyright(c) 2011 Jake Luer <jake@alogicalparadox.com>
3891
3888
  * MIT Licensed
3892
3889
  */
3893
- /*!
3894
- * Dependencies that are used for multiple exports are required here only once
3895
- */
3896
- /*!
3897
- * test utility
3898
- */
3899
- /*!
3900
- * type utility
3901
- */
3902
- /*!
3903
- * expectTypes utility
3904
- */
3905
- /*!
3906
- * message utility
3907
- */
3908
- /*!
3909
- * actual utility
3910
- */
3911
- /*!
3912
- * Inspect util
3913
- */
3914
- /*!
3915
- * Object Display util
3916
- */
3917
- /*!
3918
- * Flag utility
3919
- */
3920
- /*!
3921
- * Flag transferring utility
3922
- */
3923
- /*!
3924
- * Deep equal utility
3925
- */
3926
- /*!
3927
- * Deep path info
3928
- */
3929
- /*!
3930
- * Function name
3931
- */
3932
- /*!
3933
- * add Property
3934
- */
3935
- /*!
3936
- * add Method
3937
- */
3938
- /*!
3939
- * overwrite Property
3940
- */
3941
- /*!
3942
- * overwrite Method
3943
- */
3944
- /*!
3945
- * Add a chainable method
3946
- */
3947
- /*!
3948
- * Overwrite chainable method
3949
- */
3950
- /*!
3951
- * Compare by inspect method
3952
- */
3953
- /*!
3954
- * Get own enumerable property symbols method
3955
- */
3956
- /*!
3957
- * Get own enumerable properties method
3958
- */
3959
- /*!
3960
- * Checks error against a given set of criteria
3961
- */
3962
- /*!
3963
- * Proxify util
3964
- */
3965
- /*!
3966
- * addLengthGuard util
3967
- */
3968
- /*!
3969
- * isProxyEnabled helper
3970
- */
3971
- /*!
3972
- * isNaN method
3973
- */
3974
- /*!
3975
- * getOperator method
3976
- */
3977
3890
  /*!
3978
3891
  * chai
3979
3892
  * Copyright(c) 2011-2014 Jake Luer <jake@alogicalparadox.com>
3980
3893
  * MIT Licensed
3981
3894
  */
3982
- /*!
3983
- * ### .ifError(object)
3984
- *
3985
- * Asserts if value is not a false value, and throws if it is a true value.
3986
- * This is added to allow for chai to be a drop-in replacement for Node's
3987
- * assert class.
3988
- *
3989
- * var err = new Error('I am a custom error');
3990
- * assert.ifError(err); // Rethrows err!
3991
- *
3992
- * @name ifError
3993
- * @param {Object} object
3994
- * @namespace Assert
3995
- * @api public
3996
- */
3997
- /*!
3998
- * Aliases.
3999
- */
4000
- /*!
4001
- * Assertion Error
4002
- */
4003
- /*!
4004
- * Utility Functions
4005
- */
4006
- /*!
4007
- * Configuration
4008
- */
4009
- /*!
4010
- * Primary `Assertion` prototype
4011
- */
4012
- /*!
4013
- * Expect interface
4014
- */
4015
- /*!
4016
- * Should interface
4017
- */
4018
- /*!
4019
- * Assert interface
4020
- */
4021
3895
  /*! Bundled license information:
4022
3896
 
4023
3897
  deep-eql/index.js:
@@ -0,0 +1,12 @@
1
+ import jsdoc from "eslint-plugin-jsdoc";
2
+
3
+ export default [
4
+ jsdoc.configs["flat/recommended"],
5
+ {
6
+ rules: {
7
+ "jsdoc/require-param-description": "off",
8
+ "jsdoc/require-returns-description": "off",
9
+ "jsdoc/tag-lines": ["error", "any", { startLines: 1 }],
10
+ },
11
+ },
12
+ ];
@@ -9,7 +9,7 @@ import {config} from './config.js';
9
9
  import {AssertionError} from 'assertion-error';
10
10
  import * as util from './utils/index.js';
11
11
 
12
- /*!
12
+ /**
13
13
  * Assertion Constructor
14
14
  *
15
15
  * Creates object for chaining.
@@ -18,37 +18,37 @@ import * as util from './utils/index.js';
18
18
  * be assigned during instantiation by passing arguments to this constructor:
19
19
  *
20
20
  * - `object`: This flag contains the target of the assertion. For example, in
21
- * the assertion `expect(numKittens).to.equal(7);`, the `object` flag will
22
- * contain `numKittens` so that the `equal` assertion can reference it when
23
- * needed.
21
+ * the assertion `expect(numKittens).to.equal(7);`, the `object` flag will
22
+ * contain `numKittens` so that the `equal` assertion can reference it when
23
+ * needed.
24
24
  *
25
25
  * - `message`: This flag contains an optional custom error message to be
26
- * prepended to the error message that's generated by the assertion when it
27
- * fails.
26
+ * prepended to the error message that's generated by the assertion when it
27
+ * fails.
28
28
  *
29
29
  * - `ssfi`: This flag stands for "start stack function indicator". It
30
- * contains a function reference that serves as the starting point for
31
- * removing frames from the stack trace of the error that's created by the
32
- * assertion when it fails. The goal is to provide a cleaner stack trace to
33
- * end users by removing Chai's internal functions. Note that it only works
34
- * in environments that support `Error.captureStackTrace`, and only when
35
- * `Chai.config.includeStack` hasn't been set to `false`.
30
+ * contains a function reference that serves as the starting point for
31
+ * removing frames from the stack trace of the error that's created by the
32
+ * assertion when it fails. The goal is to provide a cleaner stack trace to
33
+ * end users by removing Chai's internal functions. Note that it only works
34
+ * in environments that support `Error.captureStackTrace`, and only when
35
+ * `Chai.config.includeStack` hasn't been set to `false`.
36
36
  *
37
37
  * - `lockSsfi`: This flag controls whether or not the given `ssfi` flag
38
- * should retain its current value, even as assertions are chained off of
39
- * this object. This is usually set to `true` when creating a new assertion
40
- * from within another assertion. It's also temporarily set to `true` before
41
- * an overwritten assertion gets called by the overwriting assertion.
38
+ * should retain its current value, even as assertions are chained off of
39
+ * this object. This is usually set to `true` when creating a new assertion
40
+ * from within another assertion. It's also temporarily set to `true` before
41
+ * an overwritten assertion gets called by the overwriting assertion.
42
42
  *
43
43
  * - `eql`: This flag contains the deepEqual function to be used by the assertion.
44
44
  *
45
- * @param {Mixed} obj target of the assertion
46
- * @param {String} msg (optional) custom error message
45
+ * @param {unknown} obj target of the assertion
46
+ * @param {string} msg (optional) custom error message
47
47
  * @param {Function} ssfi (optional) starting point for removing stack frames
48
- * @param {Boolean} lockSsfi (optional) whether or not the ssfi flag is locked
49
- * @api private
48
+ * @param {boolean} lockSsfi (optional) whether or not the ssfi flag is locked
49
+ * @returns {unknown}
50
+ * @private
50
51
  */
51
-
52
52
  export function Assertion (obj, msg, ssfi, lockSsfi) {
53
53
  util.flag(this, 'ssfi', ssfi || Assertion);
54
54
  util.flag(this, 'lockSsfi', lockSsfi);
@@ -111,13 +111,13 @@ Assertion.overwriteChainableMethod = function (name, fn, chainingBehavior) {
111
111
  * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass.
112
112
  *
113
113
  * @name assert
114
- * @param {Philosophical} expression to be tested
115
- * @param {String|Function} message or function that returns message to display if expression fails
116
- * @param {String|Function} negatedMessage or function that returns negatedMessage to display if negated expression fails
117
- * @param {Mixed} expected value (remember to check for negation)
118
- * @param {Mixed} actual (optional) will default to `this.obj`
119
- * @param {Boolean} showDiff (optional) when set to `true`, assert will display a diff in addition to the message if expression fails
120
- * @api private
114
+ * @param {unknown} expression to be tested
115
+ * @param {string | Function} message or function that returns message to display if expression fails
116
+ * @param {string | Function} negatedMessage or function that returns negatedMessage to display if negated expression fails
117
+ * @param {unknown} expected value (remember to check for negation)
118
+ * @param {unknown} actual (optional) will default to `this.obj`
119
+ * @param {boolean} showDiff (optional) when set to `true`, assert will display a diff in addition to the message if expression fails
120
+ * @private
121
121
  */
122
122
 
123
123
  Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) {
@@ -147,14 +147,13 @@ Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual,
147
147
  }
148
148
  };
149
149
 
150
- /*!
150
+ /**
151
151
  * ### ._obj
152
152
  *
153
153
  * Quick reference to stored `actual` value for plugin developers.
154
154
  *
155
- * @api private
155
+ * @private
156
156
  */
157
-
158
157
  Object.defineProperty(Assertion.prototype, '_obj',
159
158
  { get: function () {
160
159
  return util.flag(this, 'object');