chai 5.1.0 → 5.1.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.
Files changed (38) hide show
  1. package/README.md +3 -3
  2. package/chai.js +138 -79
  3. package/eslint.config.js +12 -0
  4. package/lib/chai/assertion.js +28 -28
  5. package/lib/chai/config.js +18 -24
  6. package/lib/chai/core/assertions.js +252 -255
  7. package/lib/chai/interface/assert.js +438 -390
  8. package/lib/chai/interface/expect.js +7 -2
  9. package/lib/chai/interface/should.js +30 -20
  10. package/lib/chai/utils/addChainableMethod.js +5 -6
  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 -5
  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 -4
  20. package/lib/chai/utils/getOperator.js +8 -4
  21. package/lib/chai/utils/getOwnEnumerableProperties.js +2 -3
  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 +23 -2
  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 -3
  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 -3
  34. package/lib/chai/utils/transferFlags.js +4 -6
  35. package/lib/chai/utils/type-detect.js +4 -0
  36. package/lib/chai.js +2 -2
  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
@@ -37,7 +37,9 @@ __export(utils_exports, {
37
37
  hasProperty: () => hasProperty,
38
38
  inspect: () => inspect2,
39
39
  isNaN: () => isNaN2,
40
+ isNumeric: () => isNumeric,
40
41
  isProxyEnabled: () => isProxyEnabled,
42
+ isRegExp: () => isRegExp2,
41
43
  objDisplay: () => objDisplay,
42
44
  overwriteChainableMethod: () => overwriteChainableMethod,
43
45
  overwriteMethod: () => overwriteMethod,
@@ -57,14 +59,22 @@ __export(check_error_exports, {
57
59
  getConstructorName: () => getConstructorName,
58
60
  getMessage: () => getMessage
59
61
  });
62
+ function isErrorInstance(obj) {
63
+ return obj instanceof Error || Object.prototype.toString.call(obj) === "[object Error]";
64
+ }
65
+ __name(isErrorInstance, "isErrorInstance");
66
+ function isRegExp(obj) {
67
+ return Object.prototype.toString.call(obj) === "[object RegExp]";
68
+ }
69
+ __name(isRegExp, "isRegExp");
60
70
  function compatibleInstance(thrown, errorLike) {
61
- return errorLike instanceof Error && thrown === errorLike;
71
+ return isErrorInstance(errorLike) && thrown === errorLike;
62
72
  }
63
73
  __name(compatibleInstance, "compatibleInstance");
64
74
  function compatibleConstructor(thrown, errorLike) {
65
- if (errorLike instanceof Error) {
75
+ if (isErrorInstance(errorLike)) {
66
76
  return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor;
67
- } else if (errorLike.prototype instanceof Error || errorLike === Error) {
77
+ } else if ((typeof errorLike === "object" || typeof errorLike === "function") && errorLike.prototype) {
68
78
  return thrown.constructor === errorLike || thrown instanceof errorLike;
69
79
  }
70
80
  return false;
@@ -72,7 +82,7 @@ function compatibleConstructor(thrown, errorLike) {
72
82
  __name(compatibleConstructor, "compatibleConstructor");
73
83
  function compatibleMessage(thrown, errMatcher) {
74
84
  const comparisonString = typeof thrown === "string" ? thrown : thrown.message;
75
- if (errMatcher instanceof RegExp) {
85
+ if (isRegExp(errMatcher)) {
76
86
  return errMatcher.test(comparisonString);
77
87
  } else if (typeof errMatcher === "string") {
78
88
  return comparisonString.indexOf(errMatcher) !== -1;
@@ -82,7 +92,7 @@ function compatibleMessage(thrown, errMatcher) {
82
92
  __name(compatibleMessage, "compatibleMessage");
83
93
  function getConstructorName(errorLike) {
84
94
  let constructorName = errorLike;
85
- if (errorLike instanceof Error) {
95
+ if (isErrorInstance(errorLike)) {
86
96
  constructorName = errorLike.constructor.name;
87
97
  } else if (typeof errorLike === "function") {
88
98
  constructorName = errorLike.name;
@@ -293,6 +303,10 @@ function normaliseOptions({
293
303
  return options;
294
304
  }
295
305
  __name(normaliseOptions, "normaliseOptions");
306
+ function isHighSurrogate(char) {
307
+ return char >= "\uD800" && char <= "\uDBFF";
308
+ }
309
+ __name(isHighSurrogate, "isHighSurrogate");
296
310
  function truncate(string, length, tail = truncator) {
297
311
  string = String(string);
298
312
  const tailLength = tail.length;
@@ -301,7 +315,11 @@ function truncate(string, length, tail = truncator) {
301
315
  return tail;
302
316
  }
303
317
  if (stringLength > length && stringLength > tailLength) {
304
- return `${string.slice(0, length - tailLength)}${tail}`;
318
+ let end = length - tailLength;
319
+ if (end > 0 && isHighSurrogate(string[end - 1])) {
320
+ end = end - 1;
321
+ }
322
+ return `${string.slice(0, end)}${tail}`;
305
323
  }
306
324
  return string;
307
325
  }
@@ -578,7 +596,7 @@ function inspectObject(object, options) {
578
596
  }
579
597
  options.truncate -= 4;
580
598
  options.seen = options.seen || [];
581
- if (options.seen.indexOf(object) >= 0) {
599
+ if (options.seen.includes(object)) {
582
600
  return "[Circular]";
583
601
  }
584
602
  options.seen.push(object);
@@ -629,7 +647,8 @@ var errorKeys = [
629
647
  "lineNumber",
630
648
  "columnNumber",
631
649
  "number",
632
- "description"
650
+ "description",
651
+ "cause"
633
652
  ];
634
653
  function inspectObject2(error, options) {
635
654
  const properties = Object.getOwnPropertyNames(error).filter((key) => errorKeys.indexOf(key) === -1);
@@ -643,6 +662,11 @@ function inspectObject2(error, options) {
643
662
  }
644
663
  message = message ? `: ${message}` : "";
645
664
  options.truncate -= message.length + 5;
665
+ options.seen = options.seen || [];
666
+ if (options.seen.includes(error)) {
667
+ return "[Circular]";
668
+ }
669
+ options.seen.push(error);
646
670
  const propertyContents = inspectList(properties.map((key) => [key, error[key]]), options, inspectProperty);
647
671
  return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ""}`;
648
672
  }
@@ -805,8 +829,8 @@ var config = {
805
829
  *
806
830
  * chai.config.includeStack = true; // enable stack on error
807
831
  *
808
- * @param {Boolean}
809
- * @api public
832
+ * @param {boolean}
833
+ * @public
810
834
  */
811
835
  includeStack: false,
812
836
  /**
@@ -818,8 +842,8 @@ var config = {
818
842
  * will be true when the assertion has requested a diff
819
843
  * be shown.
820
844
  *
821
- * @param {Boolean}
822
- * @api public
845
+ * @param {boolean}
846
+ * @public
823
847
  */
824
848
  showDiff: true,
825
849
  /**
@@ -838,8 +862,8 @@ var config = {
838
862
  *
839
863
  * chai.config.truncateThreshold = 0; // disable truncating
840
864
  *
841
- * @param {Number}
842
- * @api public
865
+ * @param {number}
866
+ * @public
843
867
  */
844
868
  truncateThreshold: 40,
845
869
  /**
@@ -856,8 +880,8 @@ var config = {
856
880
  * This feature is automatically disabled regardless of this config value
857
881
  * in environments that don't support proxies.
858
882
  *
859
- * @param {Boolean}
860
- * @api public
883
+ * @param {boolean}
884
+ * @public
861
885
  */
862
886
  useProxy: true,
863
887
  /**
@@ -875,7 +899,7 @@ var config = {
875
899
  * chai.config.proxyExcludedKeys = ['then', 'inspect'];
876
900
  *
877
901
  * @param {Array}
878
- * @api public
902
+ * @public
879
903
  */
880
904
  proxyExcludedKeys: ["then", "catch", "inspect", "toJSON"],
881
905
  /**
@@ -887,18 +911,18 @@ var config = {
887
911
  *
888
912
  * // use a custom comparator
889
913
  * 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
- * })
914
+ * return chai.util.eql(expected, actual, {
915
+ * comparator: (expected, actual) => {
916
+ * // for non number comparison, use the default behavior
917
+ * if(typeof expected !== 'number') return null;
918
+ * // allow a difference of 10 between compared numbers
919
+ * return typeof actual === 'number' && Math.abs(actual - expected) < 10
920
+ * }
921
+ * })
898
922
  * };
899
923
  *
900
924
  * @param {Function}
901
- * @api public
925
+ * @public
902
926
  */
903
927
  deepEqual: null
904
928
  };
@@ -1152,12 +1176,16 @@ function regexpEqual(leftHandOperand, rightHandOperand) {
1152
1176
  }
1153
1177
  __name(regexpEqual, "regexpEqual");
1154
1178
  function entriesEqual(leftHandOperand, rightHandOperand, options) {
1155
- if (leftHandOperand.size !== rightHandOperand.size) {
1179
+ try {
1180
+ if (leftHandOperand.size !== rightHandOperand.size) {
1181
+ return false;
1182
+ }
1183
+ if (leftHandOperand.size === 0) {
1184
+ return true;
1185
+ }
1186
+ } catch (sizeError) {
1156
1187
  return false;
1157
1188
  }
1158
- if (leftHandOperand.size === 0) {
1159
- return true;
1160
- }
1161
1189
  var leftHandItems = [];
1162
1190
  var rightHandItems = [];
1163
1191
  leftHandOperand.forEach(/* @__PURE__ */ __name(function gatherEntries(key, value) {
@@ -1809,6 +1837,14 @@ function getName(fn) {
1809
1837
  return fn.name;
1810
1838
  }
1811
1839
  __name(getName, "getName");
1840
+ function isRegExp2(obj) {
1841
+ return Object.prototype.toString.call(obj) === "[object RegExp]";
1842
+ }
1843
+ __name(isRegExp2, "isRegExp");
1844
+ function isNumeric(obj) {
1845
+ return ["Number", "BigInt"].includes(type(obj));
1846
+ }
1847
+ __name(isNumeric, "isNumeric");
1812
1848
 
1813
1849
  // lib/chai/core/assertions.js
1814
1850
  var { flag: flag2 } = utils_exports;
@@ -1995,6 +2031,15 @@ Assertion.addProperty("true", function() {
1995
2031
  flag2(this, "negate") ? false : true
1996
2032
  );
1997
2033
  });
2034
+ Assertion.addProperty("numeric", function() {
2035
+ const object = flag2(this, "object");
2036
+ this.assert(
2037
+ ["Number", "BigInt"].includes(type(object)),
2038
+ "expected #{this} to be numeric",
2039
+ "expected #{this} to not be numeric",
2040
+ flag2(this, "negate") ? false : true
2041
+ );
2042
+ });
1998
2043
  Assertion.addProperty("callable", function() {
1999
2044
  const val = flag2(this, "object");
2000
2045
  const ssfi = flag2(this, "ssfi");
@@ -2143,22 +2188,17 @@ Assertion.addMethod("eqls", assertEql);
2143
2188
  function assertAbove(n, msg) {
2144
2189
  if (msg)
2145
2190
  flag2(this, "message", msg);
2146
- var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase(), errorMessage, shouldThrow = true;
2191
+ var obj = flag2(this, "object"), doLength = flag2(this, "doLength"), flagMsg = flag2(this, "message"), msgPrefix = flagMsg ? flagMsg + ": " : "", ssfi = flag2(this, "ssfi"), objType = type(obj).toLowerCase(), nType = type(n).toLowerCase();
2147
2192
  if (doLength && objType !== "map" && objType !== "set") {
2148
2193
  new Assertion(obj, flagMsg, ssfi, true).to.have.property("length");
2149
2194
  }
2150
2195
  if (!doLength && (objType === "date" && nType !== "date")) {
2151
- errorMessage = msgPrefix + "the argument to above must be a date";
2152
- } else if (nType !== "number" && (doLength || objType === "number")) {
2153
- errorMessage = msgPrefix + "the argument to above must be a number";
2154
- } else if (!doLength && (objType !== "date" && objType !== "number")) {
2196
+ throw new AssertionError(msgPrefix + "the argument to above must be a date", void 0, ssfi);
2197
+ } else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
2198
+ throw new AssertionError(msgPrefix + "the argument to above must be a number", void 0, ssfi);
2199
+ } else if (!doLength && (objType !== "date" && !isNumeric(obj))) {
2155
2200
  var printObj = objType === "string" ? "'" + obj + "'" : obj;
2156
- errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
2157
- } else {
2158
- shouldThrow = false;
2159
- }
2160
- if (shouldThrow) {
2161
- throw new AssertionError(errorMessage, void 0, ssfi);
2201
+ throw new AssertionError(msgPrefix + "expected " + printObj + " to be a number or a date", void 0, ssfi);
2162
2202
  }
2163
2203
  if (doLength) {
2164
2204
  var descriptor = "length", itemsCount;
@@ -2197,9 +2237,9 @@ function assertLeast(n, msg) {
2197
2237
  }
2198
2238
  if (!doLength && (objType === "date" && nType !== "date")) {
2199
2239
  errorMessage = msgPrefix + "the argument to least must be a date";
2200
- } else if (nType !== "number" && (doLength || objType === "number")) {
2240
+ } else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
2201
2241
  errorMessage = msgPrefix + "the argument to least must be a number";
2202
- } else if (!doLength && (objType !== "date" && objType !== "number")) {
2242
+ } else if (!doLength && (objType !== "date" && !isNumeric(obj))) {
2203
2243
  var printObj = objType === "string" ? "'" + obj + "'" : obj;
2204
2244
  errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
2205
2245
  } else {
@@ -2245,9 +2285,9 @@ function assertBelow(n, msg) {
2245
2285
  }
2246
2286
  if (!doLength && (objType === "date" && nType !== "date")) {
2247
2287
  errorMessage = msgPrefix + "the argument to below must be a date";
2248
- } else if (nType !== "number" && (doLength || objType === "number")) {
2288
+ } else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
2249
2289
  errorMessage = msgPrefix + "the argument to below must be a number";
2250
- } else if (!doLength && (objType !== "date" && objType !== "number")) {
2290
+ } else if (!doLength && (objType !== "date" && !isNumeric(obj))) {
2251
2291
  var printObj = objType === "string" ? "'" + obj + "'" : obj;
2252
2292
  errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
2253
2293
  } else {
@@ -2293,9 +2333,9 @@ function assertMost(n, msg) {
2293
2333
  }
2294
2334
  if (!doLength && (objType === "date" && nType !== "date")) {
2295
2335
  errorMessage = msgPrefix + "the argument to most must be a date";
2296
- } else if (nType !== "number" && (doLength || objType === "number")) {
2336
+ } else if (!isNumeric(n) && (doLength || isNumeric(obj))) {
2297
2337
  errorMessage = msgPrefix + "the argument to most must be a number";
2298
- } else if (!doLength && (objType !== "date" && objType !== "number")) {
2338
+ } else if (!doLength && (objType !== "date" && !isNumeric(obj))) {
2299
2339
  var printObj = objType === "string" ? "'" + obj + "'" : obj;
2300
2340
  errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
2301
2341
  } else {
@@ -2341,9 +2381,9 @@ Assertion.addMethod("within", function(start, finish, msg) {
2341
2381
  }
2342
2382
  if (!doLength && (objType === "date" && (startType !== "date" || finishType !== "date"))) {
2343
2383
  errorMessage = msgPrefix + "the arguments to within must be dates";
2344
- } else if ((startType !== "number" || finishType !== "number") && (doLength || objType === "number")) {
2384
+ } else if ((!isNumeric(start) || !isNumeric(finish)) && (doLength || isNumeric(obj))) {
2345
2385
  errorMessage = msgPrefix + "the arguments to within must be numbers";
2346
- } else if (!doLength && (objType !== "date" && objType !== "number")) {
2386
+ } else if (!doLength && (objType !== "date" && !isNumeric(obj))) {
2347
2387
  var printObj = objType === "string" ? "'" + obj + "'" : obj;
2348
2388
  errorMessage = msgPrefix + "expected " + printObj + " to be a number or a date";
2349
2389
  } else {
@@ -2659,14 +2699,16 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
2659
2699
  flag2(this, "message", msg);
2660
2700
  var obj = flag2(this, "object"), ssfi = flag2(this, "ssfi"), flagMsg = flag2(this, "message"), negate = flag2(this, "negate") || false;
2661
2701
  new Assertion(obj, flagMsg, ssfi, true).is.a("function");
2662
- if (errorLike instanceof RegExp || typeof errorLike === "string") {
2702
+ if (isRegExp2(errorLike) || typeof errorLike === "string") {
2663
2703
  errMsgMatcher = errorLike;
2664
2704
  errorLike = null;
2665
2705
  }
2666
- var caughtErr;
2706
+ let caughtErr;
2707
+ let errorWasThrown = false;
2667
2708
  try {
2668
2709
  obj();
2669
2710
  } catch (err) {
2711
+ errorWasThrown = true;
2670
2712
  caughtErr = err;
2671
2713
  }
2672
2714
  var everyArgIsUndefined = errorLike === void 0 && errMsgMatcher === void 0;
@@ -2680,12 +2722,23 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
2680
2722
  } else if (errorLike) {
2681
2723
  errorLikeString = check_error_exports.getConstructorName(errorLike);
2682
2724
  }
2725
+ let actual = caughtErr;
2726
+ if (caughtErr instanceof Error) {
2727
+ actual = caughtErr.toString();
2728
+ } else if (typeof caughtErr === "string") {
2729
+ actual = caughtErr;
2730
+ } else if (caughtErr && (typeof caughtErr === "object" || typeof caughtErr === "function")) {
2731
+ try {
2732
+ actual = check_error_exports.getConstructorName(caughtErr);
2733
+ } catch (_err) {
2734
+ }
2735
+ }
2683
2736
  this.assert(
2684
- caughtErr,
2737
+ errorWasThrown,
2685
2738
  "expected #{this} to throw " + errorLikeString,
2686
2739
  "expected #{this} to not throw an error but #{act} was thrown",
2687
2740
  errorLike && errorLike.toString(),
2688
- caughtErr instanceof Error ? caughtErr.toString() : typeof caughtErr === "string" ? caughtErr : caughtErr && check_error_exports.getConstructorName(caughtErr)
2741
+ actual
2689
2742
  );
2690
2743
  }
2691
2744
  if (errorLike && caughtErr) {
@@ -2722,7 +2775,7 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
2722
2775
  }
2723
2776
  if (caughtErr && errMsgMatcher !== void 0 && errMsgMatcher !== null) {
2724
2777
  var placeholder = "including";
2725
- if (errMsgMatcher instanceof RegExp) {
2778
+ if (isRegExp2(errMsgMatcher)) {
2726
2779
  placeholder = "matching";
2727
2780
  }
2728
2781
  var isCompatibleMessage = check_error_exports.compatibleMessage(caughtErr, errMsgMatcher);
@@ -2791,18 +2844,18 @@ function closeTo(expected, delta, msg) {
2791
2844
  if (msg)
2792
2845
  flag2(this, "message", msg);
2793
2846
  var obj = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
2794
- new Assertion(obj, flagMsg, ssfi, true).is.a("number");
2795
- if (typeof expected !== "number" || typeof delta !== "number") {
2796
- flagMsg = flagMsg ? flagMsg + ": " : "";
2797
- var deltaMessage = delta === void 0 ? ", and a delta is required" : "";
2798
- throw new AssertionError(
2799
- flagMsg + "the arguments to closeTo or approximately must be numbers" + deltaMessage,
2800
- void 0,
2801
- ssfi
2802
- );
2803
- }
2847
+ new Assertion(obj, flagMsg, ssfi, true).is.numeric;
2848
+ let message = "A `delta` value is required for `closeTo`";
2849
+ if (delta == void 0)
2850
+ throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, void 0, ssfi);
2851
+ new Assertion(delta, flagMsg, ssfi, true).is.numeric;
2852
+ message = "A `expected` value is required for `closeTo`";
2853
+ if (expected == void 0)
2854
+ throw new AssertionError(flagMsg ? `${flagMsg}: ${message}` : message, void 0, ssfi);
2855
+ new Assertion(expected, flagMsg, ssfi, true).is.numeric;
2856
+ const abs = /* @__PURE__ */ __name((x) => x < 0n ? -x : x, "abs");
2804
2857
  this.assert(
2805
- Math.abs(obj - expected) <= delta,
2858
+ abs(obj - expected) <= delta,
2806
2859
  "expected #{this} to be close to " + expected + " +/- " + delta,
2807
2860
  "expected #{this} not to be close to " + expected + " +/- " + delta
2808
2861
  );
@@ -3126,8 +3179,8 @@ function loadShould() {
3126
3179
  operator
3127
3180
  }, should2.fail);
3128
3181
  };
3129
- should2.equal = function(val1, val2, msg) {
3130
- new Assertion(val1, msg).to.equal(val2);
3182
+ should2.equal = function(actual, expected, message) {
3183
+ new Assertion(actual, message).to.equal(expected);
3131
3184
  };
3132
3185
  should2.Throw = function(fn, errt, errs, msg) {
3133
3186
  new Assertion(fn, msg).to.Throw(errt, errs);
@@ -3136,8 +3189,8 @@ function loadShould() {
3136
3189
  new Assertion(val, msg).to.exist;
3137
3190
  };
3138
3191
  should2.not = {};
3139
- should2.not.equal = function(val1, val2, msg) {
3140
- new Assertion(val1, msg).to.not.equal(val2);
3192
+ should2.not.equal = function(actual, expected, msg) {
3193
+ new Assertion(actual, msg).to.not.equal(expected);
3141
3194
  };
3142
3195
  should2.not.Throw = function(fn, errt, errs, msg) {
3143
3196
  new Assertion(fn, msg).to.not.Throw(errt, errs);
@@ -3248,8 +3301,8 @@ assert.isNotNull = function(val, msg) {
3248
3301
  assert.isNaN = function(val, msg) {
3249
3302
  new Assertion(val, msg, assert.isNaN, true).to.be.NaN;
3250
3303
  };
3251
- assert.isNotNaN = function(val, msg) {
3252
- new Assertion(val, msg, assert.isNotNaN, true).not.to.be.NaN;
3304
+ assert.isNotNaN = function(value, message) {
3305
+ new Assertion(value, message, assert.isNotNaN, true).not.to.be.NaN;
3253
3306
  };
3254
3307
  assert.exists = function(val, msg) {
3255
3308
  new Assertion(val, msg, assert.exists, true).to.exist;
@@ -3263,11 +3316,11 @@ assert.isUndefined = function(val, msg) {
3263
3316
  assert.isDefined = function(val, msg) {
3264
3317
  new Assertion(val, msg, assert.isDefined, true).to.not.equal(void 0);
3265
3318
  };
3266
- assert.isCallable = function(val, msg) {
3267
- new Assertion(val, msg, assert.isCallable, true).is.callable;
3319
+ assert.isCallable = function(value, message) {
3320
+ new Assertion(value, message, assert.isCallable, true).is.callable;
3268
3321
  };
3269
- assert.isNotCallable = function(val, msg) {
3270
- new Assertion(val, msg, assert.isNotCallable, true).is.not.callable;
3322
+ assert.isNotCallable = function(value, message) {
3323
+ new Assertion(value, message, assert.isNotCallable, true).is.not.callable;
3271
3324
  };
3272
3325
  assert.isObject = function(val, msg) {
3273
3326
  new Assertion(val, msg, assert.isObject, true).to.be.a("object");
@@ -3293,6 +3346,12 @@ assert.isNumber = function(val, msg) {
3293
3346
  assert.isNotNumber = function(val, msg) {
3294
3347
  new Assertion(val, msg, assert.isNotNumber, true).to.not.be.a("number");
3295
3348
  };
3349
+ assert.isNumeric = function(val, msg) {
3350
+ new Assertion(val, msg, assert.isNumeric, true).is.numeric;
3351
+ };
3352
+ assert.isNotNumeric = function(val, msg) {
3353
+ new Assertion(val, msg, assert.isNotNumeric, true).is.not.numeric;
3354
+ };
3296
3355
  assert.isFinite = function(val, msg) {
3297
3356
  new Assertion(val, msg, assert.isFinite, true).to.be.finite;
3298
3357
  };
@@ -3305,8 +3364,8 @@ assert.isNotBoolean = function(val, msg) {
3305
3364
  assert.typeOf = function(val, type3, msg) {
3306
3365
  new Assertion(val, msg, assert.typeOf, true).to.be.a(type3);
3307
3366
  };
3308
- assert.notTypeOf = function(val, type3, msg) {
3309
- new Assertion(val, msg, assert.notTypeOf, true).to.not.be.a(type3);
3367
+ assert.notTypeOf = function(value, type3, message) {
3368
+ new Assertion(value, message, assert.notTypeOf, true).to.not.be.a(type3);
3310
3369
  };
3311
3370
  assert.instanceOf = function(val, type3, msg) {
3312
3371
  new Assertion(val, msg, assert.instanceOf, true).to.be.instanceOf(type3);
@@ -3451,12 +3510,12 @@ assert.throws = function(fn, errorLike, errMsgMatcher, msg) {
3451
3510
  var assertErr = new Assertion(fn, msg, assert.throws, true).to.throw(errorLike, errMsgMatcher);
3452
3511
  return flag(assertErr, "object");
3453
3512
  };
3454
- assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, msg) {
3513
+ assert.doesNotThrow = function(fn, errorLike, errMsgMatcher, message) {
3455
3514
  if ("string" === typeof errorLike || errorLike instanceof RegExp) {
3456
3515
  errMsgMatcher = errorLike;
3457
3516
  errorLike = null;
3458
3517
  }
3459
- new Assertion(fn, msg, assert.doesNotThrow, true).to.not.throw(errorLike, errMsgMatcher);
3518
+ new Assertion(fn, message, assert.doesNotThrow, true).to.not.throw(errorLike, errMsgMatcher);
3460
3519
  };
3461
3520
  assert.operator = function(val, operator, val2, msg) {
3462
3521
  var ok;
@@ -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
+ ];
@@ -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) {
@@ -152,7 +152,7 @@ Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual,
152
152
  *
153
153
  * Quick reference to stored `actual` value for plugin developers.
154
154
  *
155
- * @api private
155
+ * @private
156
156
  */
157
157
  Object.defineProperty(Assertion.prototype, '_obj',
158
158
  { get: function () {