qunitx 1.2.17 → 1.2.18

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/dist/.build-hash CHANGED
@@ -1 +1 @@
1
- 4f0a0493a873ddcd21496f702adc5c30174154d8
1
+ 593d6af329c5ec9ec637346d60093a8b0442c988
@@ -150,7 +150,7 @@ var require_qunit = __commonJS({
150
150
  var g = getGlobalThis();
151
151
  var console$1 = g.console;
152
152
  var setTimeout$1 = g.setTimeout;
153
- var clearTimeout2 = g.clearTimeout;
153
+ var clearTimeout = g.clearTimeout;
154
154
  var process$1 = g.process;
155
155
  var window$1 = g.window;
156
156
  var document = window$1 && window$1.document;
@@ -168,22 +168,22 @@ var require_qunit = __commonJS({
168
168
  var StringMap = typeof g.Map === "function" && typeof g.Map.prototype.keys === "function" && typeof g.Symbol === "function" && _typeof(g.Symbol.iterator) === "symbol" ? g.Map : function StringMap2(input) {
169
169
  var _this = this;
170
170
  var store = /* @__PURE__ */ Object.create(null);
171
- var hasOwn3 = Object.prototype.hasOwnProperty;
171
+ var hasOwn2 = Object.prototype.hasOwnProperty;
172
172
  this.has = function(strKey) {
173
- return hasOwn3.call(store, strKey);
173
+ return hasOwn2.call(store, strKey);
174
174
  };
175
175
  this.get = function(strKey) {
176
176
  return store[strKey];
177
177
  };
178
178
  this.set = function(strKey, val) {
179
- if (!hasOwn3.call(store, strKey)) {
179
+ if (!hasOwn2.call(store, strKey)) {
180
180
  this.size++;
181
181
  }
182
182
  store[strKey] = val;
183
183
  return this;
184
184
  };
185
185
  this.delete = function(strKey) {
186
- if (hasOwn3.call(store, strKey)) {
186
+ if (hasOwn2.call(store, strKey)) {
187
187
  delete store[strKey];
188
188
  this.size--;
189
189
  }
@@ -242,25 +242,25 @@ var require_qunit = __commonJS({
242
242
  } : function(elem, array) {
243
243
  return array.indexOf(elem) !== -1;
244
244
  };
245
- function objectValues2(obj) {
245
+ function objectValues(obj) {
246
246
  var allowArray = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
247
247
  var vals = allowArray && is("array", obj) ? [] : {};
248
248
  for (var key in obj) {
249
249
  if (hasOwn$1.call(obj, key)) {
250
250
  var val = obj[key];
251
- vals[key] = val === Object(val) ? objectValues2(val, allowArray) : val;
251
+ vals[key] = val === Object(val) ? objectValues(val, allowArray) : val;
252
252
  }
253
253
  }
254
254
  return vals;
255
255
  }
256
- function objectValuesSubset2(obj, model) {
256
+ function objectValuesSubset(obj, model) {
257
257
  if (obj !== Object(obj)) {
258
258
  return obj;
259
259
  }
260
260
  var subset = {};
261
261
  for (var key in model) {
262
262
  if (hasOwn$1.call(model, key) && hasOwn$1.call(obj, key)) {
263
- subset[key] = objectValuesSubset2(obj[key], model[key]);
263
+ subset[key] = objectValuesSubset(obj[key], model[key]);
264
264
  }
265
265
  }
266
266
  return subset;
@@ -277,7 +277,7 @@ var require_qunit = __commonJS({
277
277
  }
278
278
  return a;
279
279
  }
280
- function objectType2(obj) {
280
+ function objectType(obj) {
281
281
  if (typeof obj === "undefined") {
282
282
  return "undefined";
283
283
  }
@@ -307,7 +307,7 @@ var require_qunit = __commonJS({
307
307
  }
308
308
  }
309
309
  function is(type, obj) {
310
- return objectType2(obj) === type;
310
+ return objectType(obj) === type;
311
311
  }
312
312
  function generateHash(module3, testName) {
313
313
  var str = module3 + "" + testName;
@@ -322,7 +322,7 @@ var require_qunit = __commonJS({
322
322
  }
323
323
  return hex.slice(-8);
324
324
  }
325
- function errorString2(error) {
325
+ function errorString(error) {
326
326
  var resultErrorString = String(error);
327
327
  if (resultErrorString.slice(0, 7) === "[object") {
328
328
  return (error.name || "Error") + (error.message ? ": ".concat(error.message) : "");
@@ -485,8 +485,8 @@ var require_qunit = __commonJS({
485
485
  a,
486
486
  b
487
487
  });
488
- var aObjType = objectType2(a);
489
- var bObjType = objectType2(b);
488
+ var aObjType = objectType(a);
489
+ var bObjType = objectType(b);
490
490
  if (aObjType !== "object" || bObjType !== "object") {
491
491
  return aObjType === bObjType && objTypeCallbacks[aObjType](a, b);
492
492
  }
@@ -517,7 +517,7 @@ var require_qunit = __commonJS({
517
517
  var aType = _typeof(a);
518
518
  var bType = _typeof(b);
519
519
  if (aType !== bType) {
520
- return (aType === "object" && BOXABLE_TYPES.has(objectType2(a)) ? a.valueOf() : a) === (bType === "object" && BOXABLE_TYPES.has(objectType2(b)) ? b.valueOf() : b);
520
+ return (aType === "object" && BOXABLE_TYPES.has(objectType(a)) ? a.valueOf() : a) === (bType === "object" && BOXABLE_TYPES.has(objectType(b)) ? b.valueOf() : b);
521
521
  }
522
522
  return entryTypeCallbacks[aType](a, b);
523
523
  }
@@ -1317,7 +1317,7 @@ var require_qunit = __commonJS({
1317
1317
  }
1318
1318
  this.test.timeout = duration;
1319
1319
  if (config.timeout) {
1320
- clearTimeout2(config.timeout);
1320
+ clearTimeout(config.timeout);
1321
1321
  config.timeout = null;
1322
1322
  if (config.timeoutHandler && this.test.timeout > 0) {
1323
1323
  this.test.internalResetTimeout(this.test.timeout);
@@ -1484,8 +1484,8 @@ var require_qunit = __commonJS({
1484
1484
  }, {
1485
1485
  key: "propEqual",
1486
1486
  value: function propEqual(actual, expected, message) {
1487
- actual = objectValues2(actual);
1488
- expected = objectValues2(expected);
1487
+ actual = objectValues(actual);
1488
+ expected = objectValues(expected);
1489
1489
  this.pushResult({
1490
1490
  result: equiv(actual, expected),
1491
1491
  actual,
@@ -1496,8 +1496,8 @@ var require_qunit = __commonJS({
1496
1496
  }, {
1497
1497
  key: "notPropEqual",
1498
1498
  value: function notPropEqual(actual, expected, message) {
1499
- actual = objectValues2(actual);
1500
- expected = objectValues2(expected);
1499
+ actual = objectValues(actual);
1500
+ expected = objectValues(expected);
1501
1501
  this.pushResult({
1502
1502
  result: !equiv(actual, expected),
1503
1503
  actual,
@@ -1509,8 +1509,8 @@ var require_qunit = __commonJS({
1509
1509
  }, {
1510
1510
  key: "propContains",
1511
1511
  value: function propContains(actual, expected, message) {
1512
- actual = objectValuesSubset2(actual, expected);
1513
- expected = objectValues2(expected, false);
1512
+ actual = objectValuesSubset(actual, expected);
1513
+ expected = objectValues(expected, false);
1514
1514
  this.pushResult({
1515
1515
  result: equiv(actual, expected),
1516
1516
  actual,
@@ -1521,8 +1521,8 @@ var require_qunit = __commonJS({
1521
1521
  }, {
1522
1522
  key: "notPropContains",
1523
1523
  value: function notPropContains(actual, expected, message) {
1524
- actual = objectValuesSubset2(actual, expected);
1525
- expected = objectValues2(expected);
1524
+ actual = objectValuesSubset(actual, expected);
1525
+ expected = objectValues(expected);
1526
1526
  this.pushResult({
1527
1527
  result: !equiv(actual, expected),
1528
1528
  actual,
@@ -1576,7 +1576,7 @@ var require_qunit = __commonJS({
1576
1576
  }, {
1577
1577
  key: "throws",
1578
1578
  value: function throws(block, expected, message) {
1579
- var _validateExpectedExce = validateExpectedExceptionArgs2(expected, message, "throws");
1579
+ var _validateExpectedExce = validateExpectedExceptionArgs(expected, message, "throws");
1580
1580
  var _validateExpectedExce2 = _slicedToArray(_validateExpectedExce, 2);
1581
1581
  expected = _validateExpectedExce2[0];
1582
1582
  message = _validateExpectedExce2[1];
@@ -1599,7 +1599,7 @@ var require_qunit = __commonJS({
1599
1599
  }
1600
1600
  currentTest.ignoreGlobalErrors = false;
1601
1601
  if (actual) {
1602
- var _validateException = validateException2(actual, expected, message);
1602
+ var _validateException = validateException(actual, expected, message);
1603
1603
  var _validateException2 = _slicedToArray(_validateException, 3);
1604
1604
  result = _validateException2[0];
1605
1605
  expected = _validateException2[1];
@@ -1608,7 +1608,7 @@ var require_qunit = __commonJS({
1608
1608
  currentTest.assert.pushResult({
1609
1609
  result,
1610
1610
  // undefined if it didn't throw
1611
- actual: actual && errorString2(actual),
1611
+ actual: actual && errorString(actual),
1612
1612
  expected,
1613
1613
  message
1614
1614
  });
@@ -1616,7 +1616,7 @@ var require_qunit = __commonJS({
1616
1616
  }, {
1617
1617
  key: "rejects",
1618
1618
  value: function rejects(promise, expected, message) {
1619
- var _validateExpectedExce3 = validateExpectedExceptionArgs2(expected, message, "rejects");
1619
+ var _validateExpectedExce3 = validateExpectedExceptionArgs(expected, message, "rejects");
1620
1620
  var _validateExpectedExce4 = _slicedToArray(_validateExpectedExce3, 2);
1621
1621
  expected = _validateExpectedExce4[0];
1622
1622
  message = _validateExpectedExce4[1];
@@ -1640,7 +1640,7 @@ var require_qunit = __commonJS({
1640
1640
  done();
1641
1641
  }, function handleRejection(actual) {
1642
1642
  var result;
1643
- var _validateException3 = validateException2(actual, expected, message);
1643
+ var _validateException3 = validateException(actual, expected, message);
1644
1644
  var _validateException4 = _slicedToArray(_validateException3, 3);
1645
1645
  result = _validateException4[0];
1646
1646
  expected = _validateException4[1];
@@ -1648,7 +1648,7 @@ var require_qunit = __commonJS({
1648
1648
  currentTest.assert.pushResult({
1649
1649
  result,
1650
1650
  // leave rejection value of undefined as-is
1651
- actual: actual && errorString2(actual),
1651
+ actual: actual && errorString(actual),
1652
1652
  expected,
1653
1653
  message
1654
1654
  });
@@ -1657,8 +1657,8 @@ var require_qunit = __commonJS({
1657
1657
  }
1658
1658
  }]);
1659
1659
  })();
1660
- function validateExpectedExceptionArgs2(expected, message, assertionMethod) {
1661
- var expectedType = objectType2(expected);
1660
+ function validateExpectedExceptionArgs(expected, message, assertionMethod) {
1661
+ var expectedType = objectType(expected);
1662
1662
  if (expectedType === "string") {
1663
1663
  if (message === void 0) {
1664
1664
  message = expected;
@@ -1675,25 +1675,25 @@ var require_qunit = __commonJS({
1675
1675
  }
1676
1676
  return [expected, message];
1677
1677
  }
1678
- function validateException2(actual, expected, message) {
1678
+ function validateException(actual, expected, message) {
1679
1679
  var result = false;
1680
- var expectedType = objectType2(expected);
1680
+ var expectedType = objectType(expected);
1681
1681
  if (!expected) {
1682
1682
  result = true;
1683
1683
  } else if (expectedType === "regexp") {
1684
- result = expected.test(errorString2(actual));
1684
+ result = expected.test(errorString(actual));
1685
1685
  expected = String(expected);
1686
1686
  } else if (expectedType === "function" && expected.prototype !== void 0 && actual instanceof expected) {
1687
1687
  result = true;
1688
1688
  } else if (expectedType === "object") {
1689
1689
  result = actual instanceof expected.constructor && actual.name === expected.name && actual.message === expected.message;
1690
- expected = errorString2(expected);
1690
+ expected = errorString(expected);
1691
1691
  } else if (expectedType === "function") {
1692
1692
  try {
1693
1693
  result = expected.call({}, actual) === true;
1694
1694
  expected = null;
1695
1695
  } catch (e) {
1696
- expected = errorString2(e);
1696
+ expected = errorString(e);
1697
1697
  }
1698
1698
  }
1699
1699
  return [result, expected, message];
@@ -2275,7 +2275,7 @@ var require_qunit = __commonJS({
2275
2275
  try {
2276
2276
  promise = hook.call(_this2.testEnvironment, _this2.assert);
2277
2277
  } catch (error) {
2278
- _this2.pushFailure("Global " + hookName + " failed on " + _this2.testName + ": " + errorString2(error), extractStacktrace(error, 0));
2278
+ _this2.pushFailure("Global " + hookName + " failed on " + _this2.testName + ": " + errorString(error), extractStacktrace(error, 0));
2279
2279
  return;
2280
2280
  }
2281
2281
  }
@@ -2341,7 +2341,7 @@ var require_qunit = __commonJS({
2341
2341
  finish: function finish() {
2342
2342
  config.current = this;
2343
2343
  if (setTimeout$1) {
2344
- clearTimeout2(this.timeout);
2344
+ clearTimeout(this.timeout);
2345
2345
  config.timeoutHandler = null;
2346
2346
  }
2347
2347
  this.callback = void 0;
@@ -2554,7 +2554,7 @@ var require_qunit = __commonJS({
2554
2554
  * @param {number} timeoutDuration
2555
2555
  */
2556
2556
  internalResetTimeout: function internalResetTimeout(timeoutDuration) {
2557
- clearTimeout2(config.timeout);
2557
+ clearTimeout(config.timeout);
2558
2558
  config.timeout = setTimeout$1(config.timeoutHandler(timeoutDuration), timeoutDuration);
2559
2559
  },
2560
2560
  /**
@@ -2662,10 +2662,10 @@ var require_qunit = __commonJS({
2662
2662
  internalRecover(test4);
2663
2663
  };
2664
2664
  };
2665
- clearTimeout2(config.timeout);
2665
+ clearTimeout(config.timeout);
2666
2666
  config.timeout = setTimeout$1(config.timeoutHandler(timeoutDuration), timeoutDuration);
2667
2667
  } else {
2668
- clearTimeout2(config.timeout);
2668
+ clearTimeout(config.timeout);
2669
2669
  config.timeout = setTimeout$1(function() {
2670
2670
  config.timeout = null;
2671
2671
  if (!config._deprecated_timeout_shown) {
@@ -2960,12 +2960,12 @@ var require_qunit = __commonJS({
2960
2960
  return;
2961
2961
  }
2962
2962
  if (setTimeout$1) {
2963
- clearTimeout2(config.timeout);
2963
+ clearTimeout(config.timeout);
2964
2964
  config.timeout = setTimeout$1(function() {
2965
2965
  if (test4.pauses.size > 0) {
2966
2966
  return;
2967
2967
  }
2968
- clearTimeout2(config.timeout);
2968
+ clearTimeout(config.timeout);
2969
2969
  config.timeout = null;
2970
2970
  config.blocking = false;
2971
2971
  config.pq.advance();
@@ -3355,7 +3355,7 @@ var require_qunit = __commonJS({
3355
3355
  this.log("not ok ".concat(this.testCount, " ").concat($.red("global failure")));
3356
3356
  this.logError(error);
3357
3357
  }
3358
- this.log("Bail out! " + errorString2(error).split("\n")[0]);
3358
+ this.log("Bail out! " + errorString(error).split("\n")[0]);
3359
3359
  if (this.ended) {
3360
3360
  this.logError(error);
3361
3361
  }
@@ -3415,7 +3415,7 @@ var require_qunit = __commonJS({
3415
3415
  key: "logError",
3416
3416
  value: function logError(error) {
3417
3417
  var out = " ---";
3418
- out += "\n message: ".concat(prettyYamlValue(errorString2(error)));
3418
+ out += "\n message: ".concat(prettyYamlValue(errorString(error)));
3419
3419
  out += "\n severity: ".concat(prettyYamlValue("failed"));
3420
3420
  if (error && error.stack) {
3421
3421
  var fmtStack = annotateStacktrace(error.stack, $.grey, error.toString());
@@ -3634,7 +3634,7 @@ var require_qunit = __commonJS({
3634
3634
  if (config.current) {
3635
3635
  config.current.assert.pushResult({
3636
3636
  result: false,
3637
- message: "global failure: ".concat(errorString2(error)),
3637
+ message: "global failure: ".concat(errorString(error)),
3638
3638
  // We could let callers specify an offset to subtract a number of frames via
3639
3639
  // sourceFromStacktrace, in case they are a wrapper further away from the error
3640
3640
  // handler, and thus reduce some noise in the stack trace. However, we're not
@@ -3665,7 +3665,7 @@ var require_qunit = __commonJS({
3665
3665
  var DIFF_DELETE = -1;
3666
3666
  var DIFF_INSERT = 1;
3667
3667
  var DIFF_EQUAL = 0;
3668
- var hasOwn2 = Object.prototype.hasOwnProperty;
3668
+ var hasOwn = Object.prototype.hasOwnProperty;
3669
3669
  DiffMatchPatch.prototype.DiffMain = function(text1, text2, optChecklines) {
3670
3670
  var deadline = Date.now() + 1e3;
3671
3671
  if (text1 === null || text2 === null) {
@@ -4159,7 +4159,7 @@ var require_qunit = __commonJS({
4159
4159
  }
4160
4160
  var line = text.substring(lineStart, lineEnd + 1);
4161
4161
  lineStart = lineEnd + 1;
4162
- if (hasOwn2.call(lineHash, line)) {
4162
+ if (hasOwn.call(lineHash, line)) {
4163
4163
  chars += String.fromCharCode(lineHash[line]);
4164
4164
  } else {
4165
4165
  chars += String.fromCharCode(lineArrayLength);
@@ -4298,7 +4298,7 @@ var require_qunit = __commonJS({
4298
4298
  reporters,
4299
4299
  hooks,
4300
4300
  is,
4301
- objectType: objectType2,
4301
+ objectType,
4302
4302
  on,
4303
4303
  onError: onWindowError,
4304
4304
  onUncaughtException,
@@ -4453,9 +4453,9 @@ var require_qunit = __commonJS({
4453
4453
  return;
4454
4454
  }
4455
4455
  var config2 = QUnit.config;
4456
- var hasOwn3 = Object.prototype.hasOwnProperty;
4456
+ var hasOwn2 = Object.prototype.hasOwnProperty;
4457
4457
  function storeFixture() {
4458
- if (hasOwn3.call(config2, "fixture")) {
4458
+ if (hasOwn2.call(config2, "fixture")) {
4459
4459
  return;
4460
4460
  }
4461
4461
  var fixture = document.getElementById("qunit-fixture");
@@ -5237,7 +5237,7 @@ var require_qunit = __commonJS({
5237
5237
  var config2 = QUnit.config;
5238
5238
  var hiddenTests = [];
5239
5239
  var collapseNext = false;
5240
- var hasOwn3 = Object.prototype.hasOwnProperty;
5240
+ var hasOwn2 = Object.prototype.hasOwnProperty;
5241
5241
  var unfilteredUrl = setUrl({
5242
5242
  filter: void 0,
5243
5243
  module: void 0,
@@ -5332,7 +5332,7 @@ var require_qunit = __commonJS({
5332
5332
  }
5333
5333
  } else {
5334
5334
  for (var _j in val.value) {
5335
- if (hasOwn3.call(val.value, _j)) {
5335
+ if (hasOwn2.call(val.value, _j)) {
5336
5336
  urlConfigHtml += "<option value='" + escapeText(_j) + "'" + (config2[val.id] === _j ? (selection = true) && " selected='selected'" : "") + ">" + escapeText(val.value[_j]) + "</option>";
5337
5337
  }
5338
5338
  }
@@ -5394,7 +5394,7 @@ var require_qunit = __commonJS({
5394
5394
  var location = window$1.location;
5395
5395
  params = extend(extend({}, QUnit.urlParams), params);
5396
5396
  for (var key in params) {
5397
- if (hasOwn3.call(params, key) && params[key] !== void 0) {
5397
+ if (hasOwn2.call(params, key) && params[key] !== void 0) {
5398
5398
  var arrValue = [].concat(params[key]);
5399
5399
  for (var i = 0; i < arrValue.length; i++) {
5400
5400
  querystring += encodeURIComponent(key);
@@ -5918,7 +5918,7 @@ var require_qunit = __commonJS({
5918
5918
  if (!testItem) {
5919
5919
  return;
5920
5920
  }
5921
- var message = escapeText(errorString2(error));
5921
+ var message = escapeText(errorString(error));
5922
5922
  message = "<span class='test-message'>" + message + "</span>";
5923
5923
  if (error && error.stack) {
5924
5924
  message += "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeText(error.stack) + "</pre></td></tr></table>";
@@ -5974,7 +5974,7 @@ var require_qunit = __commonJS({
5974
5974
  });
5975
5975
 
5976
5976
  // shims/deno/index.ts
5977
- var import_qunit2 = __toESM(require_qunit(), 1);
5977
+ var import_qunit = __toESM(require_qunit(), 1);
5978
5978
 
5979
5979
  // jsr:https://jsr.io/@std/assert/1.0.19/assertion_error.ts
5980
5980
  var AssertionError = class extends Error {
@@ -6020,899 +6020,11 @@ var ANSI_PATTERN = new RegExp(
6020
6020
  "g"
6021
6021
  );
6022
6022
 
6023
- // shims/shared/assert.ts
6024
- var import_qunit = __toESM(require_qunit(), 1);
6025
-
6026
- // shims/shared/index.ts
6027
- var hasOwn = Object.prototype.hasOwnProperty;
6028
- var objToString = Object.prototype.toString;
6029
- function objectType(obj) {
6030
- if (obj === null) return "null";
6031
- const t = typeof obj;
6032
- switch (t) {
6033
- case "undefined":
6034
- case "string":
6035
- case "boolean":
6036
- case "function":
6037
- case "symbol":
6038
- case "bigint":
6039
- return t;
6040
- case "number":
6041
- return obj !== obj ? "nan" : "number";
6042
- }
6043
- const type = objToString.call(obj).slice(8, -1);
6044
- switch (type) {
6045
- case "Number":
6046
- return isNaN(obj) ? "nan" : "number";
6047
- case "String":
6048
- case "Boolean":
6049
- case "Array":
6050
- case "Set":
6051
- case "Map":
6052
- case "Date":
6053
- case "RegExp":
6054
- case "Function":
6055
- case "Symbol":
6056
- return type.toLowerCase();
6057
- default:
6058
- return "object";
6059
- }
6060
- }
6061
- function objectValues(obj, allowArray = true) {
6062
- const vals = allowArray && Array.isArray(obj) ? [] : {};
6063
- for (const key in obj) {
6064
- if (hasOwn.call(obj, key)) {
6065
- const val = obj[key];
6066
- const t = typeof val;
6067
- const isObjectish = val !== null && (t === "object" || t === "function");
6068
- vals[key] = isObjectish ? objectValues(val, allowArray) : val;
6069
- }
6070
- }
6071
- return vals;
6072
- }
6073
- function objectValuesSubset(obj, model) {
6074
- if (obj === null) return obj;
6075
- const objT = typeof obj;
6076
- if (objT !== "object" && objT !== "function") return obj;
6077
- const subset = {};
6078
- for (const key in model) {
6079
- if (hasOwn.call(model, key) && hasOwn.call(obj, key)) {
6080
- subset[key] = objectValuesSubset(
6081
- obj[key],
6082
- model[key]
6083
- );
6084
- }
6085
- }
6086
- return subset;
6087
- }
6088
- function validateExpectedExceptionArgs(expected, message, assertionMethod) {
6089
- const expectedType = objectType(expected);
6090
- if (expectedType === "string") {
6091
- if (message === void 0) {
6092
- message = expected;
6093
- expected = void 0;
6094
- return [expected, message];
6095
- } else {
6096
- throw new Error(
6097
- `assert.${assertionMethod} does not accept a string value for the expected argument.
6098
- Use a non-string object value (e.g. RegExp or validator function) instead if necessary.`
6099
- );
6100
- }
6101
- }
6102
- const valid = !expected || expectedType === "regexp" || expectedType === "function" || expectedType === "object";
6103
- if (!valid) {
6104
- throw new Error(`Invalid expected value type (${expectedType}) provided to assert.${assertionMethod}.`);
6105
- }
6106
- return [expected, message];
6107
- }
6108
- function validateException(actual, expected, message) {
6109
- let result = false;
6110
- const expectedType = objectType(expected);
6111
- if (!expected) {
6112
- result = true;
6113
- } else if (expectedType === "regexp") {
6114
- result = expected.test(errorString(actual));
6115
- expected = String(expected);
6116
- } else if (expectedType === "function" && expected.prototype !== void 0 && actual instanceof expected) {
6117
- result = true;
6118
- } else if (expectedType === "object") {
6119
- result = actual instanceof expected.constructor && actual.name === expected.name && actual.message === expected.message;
6120
- expected = errorString(expected);
6121
- } else if (expectedType === "function") {
6122
- try {
6123
- result = expected.call({}, actual) === true;
6124
- expected = null;
6125
- } catch (e) {
6126
- expected = errorString(e);
6127
- }
6128
- }
6129
- return [result, expected, message];
6130
- }
6131
- function errorString(error) {
6132
- const resultErrorString = String(error);
6133
- if (resultErrorString.slice(0, 7) === "[object") {
6134
- const name = error.name || "Error";
6135
- const msg = error.message;
6136
- return msg ? `${name}: ${msg}` : name;
6137
- }
6138
- return resultErrorString;
6139
- }
6140
-
6141
- // shims/shared/assert.ts
6142
- var PENDING = /* @__PURE__ */ Symbol("pending");
6143
- var Assert = class _Assert {
6144
- /** @internal Set by each runtime shim before tests run. */
6145
- static QUnit;
6146
- /** @internal Set by each runtime shim before tests run. */
6147
- static AssertionError;
6148
- /** @internal Set by each runtime shim before tests run. */
6149
- static inspect;
6150
- /** @internal Mutable test state written during the test run. */
6151
- test;
6152
- /** @internal */
6153
- constructor(module2, test3) {
6154
- this.test = test3 || module2.testContext;
6155
- }
6156
- /**
6157
- * Sets the number of milliseconds after which the current test will fail if not yet complete.
6158
- *
6159
- * @param {number} number - Timeout in milliseconds (positive integer).
6160
- * @example
6161
- * ```js
6162
- * test("slow async operation", async (assert) => {
6163
- * assert.timeout(500);
6164
- * await somethingAsync();
6165
- * assert.ok(true);
6166
- * });
6167
- * ```
6168
- */
6169
- timeout(number) {
6170
- if (!Number.isInteger(number) || number < 0) {
6171
- throw new Error("assert.timeout() expects a positive integer.");
6172
- }
6173
- this.test.timeout = number;
6174
- this.test.setTimeoutDuration(number);
6175
- }
6176
- /**
6177
- * Records a named step. Use with {@linkcode Assert.prototype.verifySteps} to assert that
6178
- * a sequence of steps occurred in the right order.
6179
- *
6180
- * @param {string} message - The step label to record.
6181
- * @example
6182
- * ```js
6183
- * test("event order", (assert) => {
6184
- * assert.expect(3);
6185
- * assert.step("step one");
6186
- * assert.step("step two");
6187
- * assert.verifySteps(["step one", "step two"]);
6188
- * });
6189
- * ```
6190
- */
6191
- step(message) {
6192
- this.test.steps.push(message);
6193
- const result = typeof message === "string" && message.length > 0;
6194
- const assertionMessage = result ? message : message === void 0 || message === "" ? "You must provide a message to assert.step" : "You must provide a string value to assert.step";
6195
- this.pushResult({ result, message: assertionMessage });
6196
- }
6197
- /**
6198
- * Asserts that the steps recorded via {@linkcode Assert.prototype.step} match the given array,
6199
- * then clears the recorded steps.
6200
- *
6201
- * @param {string[]} steps - Expected array of step labels in order.
6202
- * @param {string} [message] - Optional failure message.
6203
- * @example
6204
- * ```js
6205
- * test("lifecycle order", (assert) => {
6206
- * assert.step("init");
6207
- * assert.step("run");
6208
- * assert.verifySteps(["init", "run"]);
6209
- * });
6210
- * ```
6211
- */
6212
- verifySteps(steps, message = "Verify steps failed!") {
6213
- this.deepEqual(this.test.steps, steps, message);
6214
- this.test.steps.length = 0;
6215
- }
6216
- /**
6217
- * Sets the number of assertions expected to run in the current test.
6218
- * The test fails if a different number of assertions actually ran.
6219
- *
6220
- * @param {number} number - Expected assertion count (non-negative integer).
6221
- * @example
6222
- * ```js
6223
- * test("exactly two assertions", (assert) => {
6224
- * assert.expect(2);
6225
- * assert.ok(true);
6226
- * assert.ok(true);
6227
- * });
6228
- * ```
6229
- */
6230
- expect(number) {
6231
- if (!Number.isInteger(number) || number < 0) {
6232
- throw new Error("assert.expect() expects a positive integer.");
6233
- }
6234
- this.test.expectedAssertionCount = number;
6235
- }
6236
- /**
6237
- * Returns a `done` callback for callback-style async tests. The test will not
6238
- * finish until every `done` callback returned by `async()` has been called.
6239
- *
6240
- * For `async/await` tests prefer `async (assert) => { ... }` directly.
6241
- *
6242
- * @returns {function} A callback to invoke when the async work finishes.
6243
- * @example
6244
- * ```js
6245
- * test("async callback style", (assert) => {
6246
- * const done = assert.async();
6247
- * setTimeout(() => {
6248
- * assert.ok(true, "async callback ran");
6249
- * done();
6250
- * }, 10);
6251
- * });
6252
- * ```
6253
- */
6254
- async() {
6255
- const { promise, resolve } = Promise.withResolvers();
6256
- this.test.asyncOps.push(promise);
6257
- return resolve;
6258
- }
6259
- /** @internal Used by the test runner to wait for all async operations to complete. */
6260
- waitForAsyncOps() {
6261
- return Promise.all(this.test.asyncOps);
6262
- }
6263
- /**
6264
- * Pushes a custom assertion result. Fails the test if `resultInfo.result` is falsy.
6265
- * Throws an {@linkcode AssertionError} on failure.
6266
- *
6267
- * Useful for building custom assertion helpers.
6268
- *
6269
- * @param {{ result: boolean, actual?: unknown, expected?: unknown, message?: string }} resultInfo
6270
- * @example
6271
- * ```js
6272
- * test("custom assertion", (assert) => {
6273
- * assert.pushResult({
6274
- * result: 1 + 1 === 2,
6275
- * actual: 2,
6276
- * expected: 2,
6277
- * message: "custom math check",
6278
- * });
6279
- * });
6280
- * ```
6281
- */
6282
- pushResult(resultInfo = {}) {
6283
- this.test.totalExecutedAssertions++;
6284
- if (!resultInfo.result) {
6285
- throw new _Assert.AssertionError({
6286
- actual: resultInfo.actual,
6287
- expected: resultInfo.expected,
6288
- message: resultInfo.message || "Custom assertion failed!",
6289
- stackStartFn: this.pushResult
6290
- });
6291
- }
6292
- return this;
6293
- }
6294
- /**
6295
- * Asserts that `state` is truthy.
6296
- *
6297
- * @param {unknown} state - The value to test.
6298
- * @param {string} [message] - Optional failure message.
6299
- * @example
6300
- * ```js
6301
- * assert.ok(true);
6302
- * assert.ok(1, "non-zero is truthy");
6303
- * assert.ok("hello");
6304
- * ```
6305
- */
6306
- ok(state, message) {
6307
- this.test.totalExecutedAssertions++;
6308
- if (!state) {
6309
- throw new _Assert.AssertionError({
6310
- actual: state,
6311
- expected: true,
6312
- message: message || `Expected argument to be truthy, it was: ${inspect(state)}`,
6313
- stackStartFn: this.ok
6314
- });
6315
- }
6316
- }
6317
- /**
6318
- * Asserts that `state` is falsy.
6319
- *
6320
- * @param {unknown} state - The value to test.
6321
- * @param {string} [message] - Optional failure message.
6322
- * @example
6323
- * ```js
6324
- * assert.notOk(false);
6325
- * assert.notOk(0, "zero is falsy");
6326
- * assert.notOk(null);
6327
- * ```
6328
- */
6329
- notOk(state, message) {
6330
- this.test.totalExecutedAssertions++;
6331
- if (state) {
6332
- throw new _Assert.AssertionError({
6333
- actual: state,
6334
- expected: false,
6335
- message: message || `Expected argument to be falsy, it was: ${inspect(state)}`,
6336
- stackStartFn: this.notOk
6337
- });
6338
- }
6339
- }
6340
- /**
6341
- * Asserts that `state === true` (strict boolean true).
6342
- *
6343
- * @param {unknown} state - The value to test.
6344
- * @param {string} [message] - Optional failure message.
6345
- * @example
6346
- * ```js
6347
- * assert.true(1 === 1);
6348
- * assert.true(Array.isArray([]), "arrays are arrays");
6349
- * ```
6350
- */
6351
- true(state, message) {
6352
- this.test.totalExecutedAssertions++;
6353
- if (state !== true) {
6354
- throw new _Assert.AssertionError({
6355
- actual: state,
6356
- expected: true,
6357
- message: message || `Expected argument to be true, it was: ${inspect(state)}`,
6358
- stackStartFn: this.true
6359
- });
6360
- }
6361
- }
6362
- /**
6363
- * Asserts that `state === false` (strict boolean false).
6364
- *
6365
- * @param {unknown} state - The value to test.
6366
- * @param {string} [message] - Optional failure message.
6367
- * @example
6368
- * ```js
6369
- * assert.false(1 === 2);
6370
- * assert.false(Number.isNaN(42), "42 is not NaN");
6371
- * ```
6372
- */
6373
- false(state, message) {
6374
- this.test.totalExecutedAssertions++;
6375
- if (state !== false) {
6376
- throw new _Assert.AssertionError({
6377
- actual: state,
6378
- expected: false,
6379
- message: message || `Expected argument to be false, it was: ${inspect(state)}`,
6380
- stackStartFn: this.false
6381
- });
6382
- }
6383
- }
6384
- /**
6385
- * Asserts that `actual == expected` (loose equality, allows type coercion).
6386
- *
6387
- * Prefer {@linkcode Assert.prototype.strictEqual} for most comparisons. Use {@linkcode Assert.prototype.notEqual}
6388
- * for the inverse.
6389
- *
6390
- * @param {unknown} actual - The value produced by the code under test.
6391
- * @param {unknown} expected - The expected value.
6392
- * @param {string} [message] - Optional failure message.
6393
- * @example
6394
- * ```js
6395
- * assert.equal(1, 1);
6396
- * assert.equal("1", 1, "loose equality allows coercion");
6397
- * ```
6398
- */
6399
- equal(actual, expected, message) {
6400
- this.test.totalExecutedAssertions++;
6401
- if (actual != expected) {
6402
- throw new _Assert.AssertionError({
6403
- actual,
6404
- expected,
6405
- message: message || `Values are not equal:${formatDiff(actual, expected)}`,
6406
- operator: "==",
6407
- stackStartFn: this.equal
6408
- });
6409
- }
6410
- }
6411
- /**
6412
- * Asserts that `actual != expected` (loose inequality). Inverse of {@linkcode Assert.prototype.equal}.
6413
- *
6414
- * @param {unknown} actual - The actual value.
6415
- * @param {unknown} expected - The value it should not loosely equal.
6416
- * @param {string} [message] - Optional failure message.
6417
- * @example
6418
- * ```js
6419
- * assert.notEqual(1, 2);
6420
- * assert.notEqual("hello", "world");
6421
- * ```
6422
- */
6423
- notEqual(actual, expected, message) {
6424
- this.test.totalExecutedAssertions++;
6425
- if (actual == expected) {
6426
- throw new _Assert.AssertionError({
6427
- actual,
6428
- expected,
6429
- operator: "!=",
6430
- message: message || `Values are unexpectedly equal:${formatUnexpectedMatch(actual)}`,
6431
- stackStartFn: this.notEqual
6432
- });
6433
- }
6434
- }
6435
- /**
6436
- * Asserts that `actual` and `expected` have the same own enumerable properties
6437
- * and values. Prototype methods are ignored; only own properties are compared.
6438
- *
6439
- * @param {object} actual - The actual object.
6440
- * @param {object} expected - The expected object.
6441
- * @param {string} [message] - Optional failure message.
6442
- * @example
6443
- * ```js
6444
- * assert.propEqual({ a: 1, b: 2 }, { a: 1, b: 2 });
6445
- *
6446
- * // Ignores prototype methods — only own properties matter:
6447
- * function Point(x, y) { this.x = x; this.y = y; }
6448
- * assert.propEqual(new Point(1, 2), { x: 1, y: 2 });
6449
- * ```
6450
- */
6451
- propEqual(actual, expected, message) {
6452
- this.test.totalExecutedAssertions++;
6453
- const targetActual = objectValues(actual);
6454
- const targetExpected = objectValues(expected);
6455
- if (!_Assert.QUnit.equiv(targetActual, targetExpected)) {
6456
- throw new _Assert.AssertionError({
6457
- actual: targetActual,
6458
- expected: targetExpected,
6459
- message: message || `Own properties are not equal:${formatDiff(targetActual, targetExpected)}`,
6460
- stackStartFn: this.propEqual
6461
- });
6462
- }
6463
- }
6464
- /**
6465
- * Asserts that `actual` and `expected` do NOT have the same own enumerable
6466
- * properties and values. Inverse of {@linkcode Assert.prototype.propEqual}.
6467
- *
6468
- * @param {object} actual - The actual object.
6469
- * @param {object} expected - The value it should not propEqual.
6470
- * @param {string} [message] - Optional failure message.
6471
- * @example
6472
- * ```js
6473
- * assert.notPropEqual({ a: 1 }, { a: 2 });
6474
- * assert.notPropEqual({ a: 1, b: 2 }, { a: 1 }); // extra key makes them unequal
6475
- * ```
6476
- */
6477
- notPropEqual(actual, expected, message) {
6478
- this.test.totalExecutedAssertions++;
6479
- const targetActual = objectValues(actual);
6480
- const targetExpected = objectValues(expected);
6481
- if (_Assert.QUnit.equiv(targetActual, targetExpected)) {
6482
- throw new _Assert.AssertionError({
6483
- actual: targetActual,
6484
- expected: targetExpected,
6485
- message: message || `Own properties are unexpectedly equal:${formatUnexpectedMatch(targetActual)}`,
6486
- stackStartFn: this.notPropEqual
6487
- });
6488
- }
6489
- }
6490
- /**
6491
- * Asserts that `actual` contains all own enumerable properties from `expected`
6492
- * with matching values. Extra properties on `actual` are allowed and ignored.
6493
- *
6494
- * @param {object} actual - The actual object (may have extra keys).
6495
- * @param {object} expected - The subset of key/value pairs that must be present.
6496
- * @param {string} [message] - Optional failure message.
6497
- * @example
6498
- * ```js
6499
- * assert.propContains({ a: 1, b: 2, c: 3 }, { a: 1, b: 2 });
6500
- * assert.propContains(user, { role: "admin" });
6501
- * ```
6502
- */
6503
- propContains(actual, expected, message) {
6504
- this.test.totalExecutedAssertions++;
6505
- const targetActual = objectValuesSubset(actual, expected);
6506
- const targetExpected = objectValues(expected, false);
6507
- if (!_Assert.QUnit.equiv(targetActual, targetExpected)) {
6508
- throw new _Assert.AssertionError({
6509
- actual: targetActual,
6510
- expected: targetExpected,
6511
- message: message || `Object does not contain expected properties:${formatDiff(targetActual, targetExpected)}`,
6512
- stackStartFn: this.propContains
6513
- });
6514
- }
6515
- }
6516
- /**
6517
- * Asserts that `actual` does NOT contain all own enumerable properties
6518
- * from `expected` with matching values. Inverse of {@linkcode Assert.prototype.propContains}.
6519
- *
6520
- * @param {object} actual - The actual object.
6521
- * @param {object} expected - The subset of properties that must NOT all match.
6522
- * @param {string} [message] - Optional failure message.
6523
- * @example
6524
- * ```js
6525
- * assert.notPropContains({ a: 1, b: 2 }, { a: 9 });
6526
- * assert.notPropContains(user, { role: "banned" });
6527
- * ```
6528
- */
6529
- notPropContains(actual, expected, message) {
6530
- this.test.totalExecutedAssertions++;
6531
- const targetActual = objectValuesSubset(actual, expected);
6532
- const targetExpected = objectValues(expected);
6533
- if (_Assert.QUnit.equiv(targetActual, targetExpected)) {
6534
- throw new _Assert.AssertionError({
6535
- actual: targetActual,
6536
- expected: targetExpected,
6537
- message: message || `Object unexpectedly contains all expected properties:${formatUnexpectedMatch(targetActual)}`,
6538
- stackStartFn: this.notPropContains
6539
- });
6540
- }
6541
- }
6542
- /**
6543
- * Asserts deep equality between `actual` and `expected` using recursive structural
6544
- * comparison. Handles nested objects, arrays, `Date`, `RegExp`, and more.
6545
- *
6546
- * @param {unknown} actual - The actual value.
6547
- * @param {unknown} expected - The expected value.
6548
- * @param {string} [message] - Optional failure message.
6549
- * @example
6550
- * ```js
6551
- * assert.deepEqual([1, { a: 2 }], [1, { a: 2 }]);
6552
- * assert.deepEqual(new Date("2024-01-01"), new Date("2024-01-01"));
6553
- * ```
6554
- */
6555
- deepEqual(actual, expected, message) {
6556
- this.test.totalExecutedAssertions++;
6557
- if (!_Assert.QUnit.equiv(actual, expected)) {
6558
- throw new _Assert.AssertionError({
6559
- actual,
6560
- expected,
6561
- message: message || `Values are not deeply equal:${formatDiff(actual, expected)}`,
6562
- operator: "deepEqual",
6563
- stackStartFn: this.deepEqual
6564
- });
6565
- }
6566
- }
6567
- /**
6568
- * Asserts that `actual` and `expected` are NOT deeply equal. Inverse of {@linkcode Assert.prototype.deepEqual}.
6569
- *
6570
- * @param {unknown} actual - The actual value.
6571
- * @param {unknown} expected - The value it should not deepEqual.
6572
- * @param {string} [message] - Optional failure message.
6573
- * @example
6574
- * ```js
6575
- * assert.notDeepEqual([1, 2], [1, 3]);
6576
- * assert.notDeepEqual({ a: 1 }, { a: 2 });
6577
- * ```
6578
- */
6579
- notDeepEqual(actual, expected, message) {
6580
- this.test.totalExecutedAssertions++;
6581
- if (_Assert.QUnit.equiv(actual, expected)) {
6582
- throw new _Assert.AssertionError({
6583
- actual,
6584
- expected,
6585
- message: message || `Values are unexpectedly deeply equal:${formatUnexpectedMatch(actual)}`,
6586
- operator: "notDeepEqual",
6587
- stackStartFn: this.notDeepEqual
6588
- });
6589
- }
6590
- }
6591
- /**
6592
- * Asserts that `actual === expected` (strict equality, no type coercion).
6593
- *
6594
- * @param {unknown} actual - The actual value.
6595
- * @param {unknown} expected - The expected value.
6596
- * @param {string} [message] - Optional failure message.
6597
- * @example
6598
- * ```js
6599
- * assert.strictEqual(1 + 1, 2);
6600
- * assert.strictEqual(typeof "hello", "string");
6601
- * ```
6602
- */
6603
- strictEqual(actual, expected, message) {
6604
- this.test.totalExecutedAssertions++;
6605
- if (actual !== expected) {
6606
- throw new _Assert.AssertionError({
6607
- actual,
6608
- expected,
6609
- message: message || `Values are not strictly equal:${formatDiff(actual, expected)}`,
6610
- operator: "strictEqual",
6611
- stackStartFn: this.strictEqual
6612
- });
6613
- }
6614
- }
6615
- /**
6616
- * Asserts that `actual !== expected` (strict inequality). Inverse of {@linkcode Assert.prototype.strictEqual}.
6617
- *
6618
- * @param {unknown} actual - The actual value.
6619
- * @param {unknown} expected - The value it should not strictly equal.
6620
- * @param {string} [message] - Optional failure message.
6621
- * @example
6622
- * ```js
6623
- * assert.notStrictEqual(1, "1", "different types");
6624
- * assert.notStrictEqual({}, {}, "different object references");
6625
- * ```
6626
- */
6627
- notStrictEqual(actual, expected, message) {
6628
- this.test.totalExecutedAssertions++;
6629
- if (actual === expected) {
6630
- throw new _Assert.AssertionError({
6631
- actual,
6632
- expected,
6633
- message: message || `Values are unexpectedly strictly equal:${formatUnexpectedMatch(actual)}`,
6634
- operator: "notStrictEqual",
6635
- stackStartFn: this.notStrictEqual
6636
- });
6637
- }
6638
- }
6639
- /**
6640
- * Asserts that `blockFn` throws an exception. Optionally validates the thrown
6641
- * error against a string (message substring), RegExp (message pattern),
6642
- * or constructor (`instanceof` check). For async functions use {@linkcode Assert.prototype.rejects}.
6643
- *
6644
- * @param {function} blockFn - A synchronous function expected to throw.
6645
- * @param {string|RegExp|function} [expected] - Optional matcher for the thrown error.
6646
- * @param {string} [message] - Optional failure message.
6647
- * @example
6648
- * ```js
6649
- * assert.throws(() => { throw new Error("boom"); });
6650
- * assert.throws(() => JSON.parse("{bad}"), SyntaxError);
6651
- * assert.throws(() => { throw new Error("bad input"); }, /bad input/);
6652
- * ```
6653
- */
6654
- throws(blockFn, expectedInput, assertionMessage) {
6655
- this.test.totalExecutedAssertions++;
6656
- const [expected, message] = validateExpectedExceptionArgs(expectedInput, assertionMessage, "throws");
6657
- if (typeof blockFn !== "function") {
6658
- throw new _Assert.AssertionError({
6659
- actual: blockFn,
6660
- expected: Function,
6661
- message: "The value provided to `assert.throws` was not a function.",
6662
- stackStartFn: this.throws
6663
- });
6664
- }
6665
- let returnValue;
6666
- try {
6667
- returnValue = blockFn();
6668
- } catch (error) {
6669
- const [result, , validatedMessage] = validateException(error, expected, message);
6670
- if (result === false) {
6671
- const expectedDesc = describeExpected(expected);
6672
- const receivedDesc = String(error);
6673
- throw new _Assert.AssertionError({
6674
- actual: receivedDesc,
6675
- expected: expectedDesc,
6676
- message: validatedMessage || throwsFailMessage("throws", expectedDesc, receivedDesc),
6677
- stackStartFn: this.throws
6678
- });
6679
- }
6680
- return;
6681
- }
6682
- if (returnValue !== null && typeof returnValue === "object" && typeof returnValue.then === "function") {
6683
- throw new _Assert.AssertionError({
6684
- actual: returnValue,
6685
- expected,
6686
- message: "Function passed to `assert.throws` returned a Promise \u2014 did you mean to use `assert.rejects`?",
6687
- stackStartFn: this.throws
6688
- });
6689
- }
6690
- throw new _Assert.AssertionError({
6691
- actual: blockFn,
6692
- expected,
6693
- message: "Function passed to `assert.throws` did not throw an exception!",
6694
- stackStartFn: this.throws
6695
- });
6696
- }
6697
- /**
6698
- * Asserts that a promise rejects. Optionally validates the rejection reason
6699
- * against a string (message substring), RegExp (message pattern),
6700
- * or constructor (`instanceof` check). For synchronous throws use {@linkcode Assert.prototype.throws}.
6701
- *
6702
- * @param {Promise<unknown>} promise - A promise expected to reject.
6703
- * @param {string|RegExp|function} [expected] - Optional matcher for the rejection reason.
6704
- * @param {string} [message] - Optional failure message.
6705
- * @example
6706
- * ```js
6707
- * await assert.rejects(Promise.reject(new Error("oops")));
6708
- * await assert.rejects(fetch("/bad-url"), TypeError);
6709
- * await assert.rejects(Promise.reject(new Error("timeout")), /timeout/);
6710
- * ```
6711
- */
6712
- async rejects(promise, expectedInput, assertionMessage) {
6713
- this.test.totalExecutedAssertions++;
6714
- const [expected, message] = validateExpectedExceptionArgs(expectedInput, assertionMessage, "rejects");
6715
- const then = promise && promise.then;
6716
- if (typeof then !== "function") {
6717
- throw new _Assert.AssertionError({
6718
- actual: promise,
6719
- expected,
6720
- message: "The value provided to `assert.rejects` was not a promise!",
6721
- stackStartFn: this.rejects
6722
- });
6723
- }
6724
- let caught = PENDING;
6725
- try {
6726
- await promise;
6727
- } catch (error) {
6728
- caught = error;
6729
- }
6730
- if (caught === PENDING) {
6731
- throw new _Assert.AssertionError({
6732
- actual: promise,
6733
- expected,
6734
- message: "The promise returned by the `assert.rejects` callback did not reject!",
6735
- stackStartFn: this.rejects
6736
- });
6737
- }
6738
- const [result, , validatedMessage] = validateException(caught, expected, message);
6739
- if (result === false) {
6740
- const expectedDesc = describeExpected(expected);
6741
- const receivedDesc = String(caught);
6742
- throw new _Assert.AssertionError({
6743
- actual: receivedDesc,
6744
- expected: expectedDesc,
6745
- message: validatedMessage || throwsFailMessage("rejects", expectedDesc, receivedDesc),
6746
- stackStartFn: this.rejects
6747
- });
6748
- }
6749
- }
6750
- };
6751
- var INSPECT_OPTIONS = { depth: 10, colors: true, compact: false };
6752
- var inspect = (value) => Assert.inspect(value, INSPECT_OPTIONS);
6753
- function formatDiff(actual, expected) {
6754
- const aStr = inspect(actual), bStr = inspect(expected);
6755
- const aLines = aStr.split("\n"), bLines = bStr.split("\n");
6756
- if (aLines.length === 1 && bLines.length === 1) return `
6757
-
6758
- Actual: ${aStr}
6759
- Expected: ${bStr}`;
6760
- const lines = lcsDiff(aLines, bLines).map(
6761
- ([t, line]) => t === "=" ? ` ${line}` : t === "-" ? `- ${line}` : `+ ${line}`
6762
- );
6763
- return `
6764
-
6765
- - Actual + Expected
6766
-
6767
- ${lines.join("\n")}`;
6768
- }
6769
- var formatUnexpectedMatch = (actual) => `
6770
-
6771
- ${inspect(actual)}`;
6772
- var describeExpected = (expected) => expected == null ? "(no pattern)" : typeof expected === "string" ? expected : typeof expected === "function" ? expected.name || String(expected) : String(expected);
6773
- var throwsFailMessage = (method, pattern, received) => `assert.${method}: thrown error did not match expected:
6774
-
6775
- Pattern: ${pattern}
6776
- Received: ${received}`;
6777
- function lcsDiff(a, b) {
6778
- const m = a.length, n = b.length;
6779
- const dp = Array.from({ length: m + 1 }, () => new Array(n + 1).fill(0));
6780
- for (let i2 = 1; i2 <= m; i2++)
6781
- for (let j2 = 1; j2 <= n; j2++)
6782
- dp[i2][j2] = a[i2 - 1] === b[j2 - 1] ? dp[i2 - 1][j2 - 1] + 1 : Math.max(dp[i2 - 1][j2], dp[i2][j2 - 1]);
6783
- const result = [];
6784
- let i = m, j = n;
6785
- while (i > 0 || j > 0) {
6786
- if (i > 0 && j > 0 && a[i - 1] === b[j - 1]) {
6787
- result.push(["=", a[i - 1]]);
6788
- i--;
6789
- j--;
6790
- } else if (j > 0 && (i === 0 || dp[i][j - 1] >= dp[i - 1][j])) {
6791
- result.push(["+", b[j - 1]]);
6792
- j--;
6793
- } else {
6794
- result.push(["-", a[i - 1]]);
6795
- i--;
6796
- }
6797
- }
6798
- return result.reverse();
6799
- }
6800
-
6801
- // shims/shared/filter-stack.ts
6802
- var FILTER_PATTERNS = [
6803
- /\bnode:internal\/test_runner\//,
6804
- /\bnode:async_hooks\b/
6805
- ];
6806
- function isDebugEnabled() {
6807
- try {
6808
- const proc = globalThis.process;
6809
- if (proc?.env?.QUNITX_DEBUG === "1") return true;
6810
- const deno = globalThis.Deno;
6811
- if (deno?.env?.get?.("QUNITX_DEBUG") === "1") return true;
6812
- } catch {
6813
- }
6814
- return false;
6815
- }
6816
- function filterStack(stack) {
6817
- if (!stack || isDebugEnabled()) return stack;
6818
- return stack.split("\n").filter((line) => !FILTER_PATTERNS.some((p) => p.test(line))).join("\n");
6819
- }
6820
-
6821
- // shims/shared/test-context.ts
6822
- var TestContext = class _TestContext {
6823
- static Assert;
6824
- name;
6825
- module;
6826
- asyncOps = [];
6827
- assert;
6828
- timeout;
6829
- steps = [];
6830
- expectedAssertionCount;
6831
- totalExecutedAssertions = 0;
6832
- userContext = {};
6833
- rejectTimeout;
6834
- #timeoutHandle;
6835
- #timedOut = false;
6836
- constructor(name, moduleContext) {
6837
- if (moduleContext) {
6838
- this.name = `${moduleContext.name} | ${name}`;
6839
- this.module = moduleContext;
6840
- this.module.tests.push(this);
6841
- this.assert = new _TestContext.Assert(moduleContext, this);
6842
- }
6843
- }
6844
- setTimeoutDuration(ms) {
6845
- if (this.#timeoutHandle !== void 0) {
6846
- clearTimeout(this.#timeoutHandle);
6847
- this.#timeoutHandle = void 0;
6848
- }
6849
- if (!this.rejectTimeout) return;
6850
- this.#timeoutHandle = setTimeout(() => {
6851
- this.#timedOut = true;
6852
- this.rejectTimeout(new Error(`Test timed out after ${ms}ms`));
6853
- }, ms);
6854
- }
6855
- clearTimeoutHandle() {
6856
- if (this.#timeoutHandle !== void 0) {
6857
- clearTimeout(this.#timeoutHandle);
6858
- this.#timeoutHandle = void 0;
6859
- }
6860
- }
6861
- finish() {
6862
- if (this.#timedOut) return;
6863
- if (this.steps.length > 0) {
6864
- this.assert.pushResult({
6865
- result: false,
6866
- actual: this.steps,
6867
- expected: [],
6868
- message: `Expected assert.verifySteps() to be called before end of test after using assert.step(). Unverified steps: ${this.steps.join(", ")}`
6869
- });
6870
- } else if (this.expectedAssertionCount !== void 0 && this.expectedAssertionCount !== this.totalExecutedAssertions) {
6871
- this.assert.pushResult({
6872
- result: false,
6873
- actual: this.totalExecutedAssertions,
6874
- expected: this.expectedAssertionCount,
6875
- message: `Expected ${this.expectedAssertionCount} assertions, but ${this.totalExecutedAssertions} were run for test: ${this.name}`
6876
- });
6877
- } else if (this.expectedAssertionCount === void 0 && this.totalExecutedAssertions === 0) {
6878
- this.assert.pushResult({
6879
- result: false,
6880
- actual: this.totalExecutedAssertions,
6881
- expected: "> 0",
6882
- message: `Expected at least one assertion to be run for test: ${this.name}`
6883
- });
6884
- }
6885
- }
6886
- };
6887
-
6888
- // shims/shared/module-context.ts
6889
- var ModuleContext = class _ModuleContext {
6890
- static Assert;
6891
- static currentModuleChain = [];
6892
- static get lastModule() {
6893
- const chain = this.currentModuleChain;
6894
- return chain[chain.length - 1];
6895
- }
6896
- name;
6897
- assert;
6898
- userContext;
6899
- // Internal fallback assert for modules with no direct tests
6900
- testContext = new TestContext();
6901
- moduleChain = [];
6902
- beforeEachHooks = [];
6903
- afterEachHooks = [];
6904
- tests = [];
6905
- constructor(name) {
6906
- const chain = _ModuleContext.currentModuleChain;
6907
- const parentModule = chain[chain.length - 1];
6908
- chain.push(this);
6909
- this.moduleChain = chain.slice();
6910
- this.name = parentModule ? `${parentModule.name} > ${name}` : name;
6911
- this.assert = new _ModuleContext.Assert(this);
6912
- this.userContext = parentModule ? Object.create(parentModule.userContext) : /* @__PURE__ */ Object.create(null);
6913
- return Object.freeze(this);
6914
- }
6915
- };
6023
+ // shims/deno/index.ts
6024
+ import Assert from "../shared/assert.js";
6025
+ import { filterStack } from "../shared/filter-stack.js";
6026
+ import ModuleContext3 from "../shared/module-context.js";
6027
+ import TestContext2 from "../shared/test-context.js";
6916
6028
 
6917
6029
  // jsr:https://jsr.io/@std/internal/1.0.12/assertion_state.ts
6918
6030
  var AssertionState = class {
@@ -7703,6 +6815,7 @@ describe.skip = function describeSkip(...args) {
7703
6815
  };
7704
6816
 
7705
6817
  // shims/deno/module.ts
6818
+ import ModuleContext from "../shared/module-context.js";
7706
6819
  function module(moduleName, runtimeOptions, moduleContent) {
7707
6820
  const targetRuntimeOptions = moduleContent ? runtimeOptions : {};
7708
6821
  const { skip: skip2 } = targetRuntimeOptions;
@@ -7764,8 +6877,10 @@ module.todo = function todoModule(moduleName, _moduleContent) {
7764
6877
  };
7765
6878
 
7766
6879
  // shims/deno/test.ts
6880
+ import ModuleContext2 from "../shared/module-context.js";
6881
+ import TestContext from "../shared/test-context.js";
7767
6882
  function test2(testName, runtimeOptions, testContent) {
7768
- const moduleContext = ModuleContext.lastModule;
6883
+ const moduleContext = ModuleContext2.lastModule;
7769
6884
  if (!moduleContext) {
7770
6885
  throw new Error(`Test '${testName}' called outside of module context.`);
7771
6886
  }
@@ -7830,11 +6945,11 @@ var AssertionError2 = class extends AssertionError {
7830
6945
  Assert.QUnit = globalThis.QUnit;
7831
6946
  Assert.AssertionError = AssertionError2;
7832
6947
  Assert.inspect = Deno.inspect;
7833
- ModuleContext.Assert = Assert;
7834
- TestContext.Assert = Assert;
6948
+ ModuleContext3.Assert = Assert;
6949
+ TestContext2.Assert = Assert;
7835
6950
  Object.freeze(Assert);
7836
- Object.freeze(ModuleContext);
7837
- Object.freeze(TestContext);
6951
+ Object.freeze(ModuleContext3);
6952
+ Object.freeze(TestContext2);
7838
6953
  var skip = test2.skip;
7839
6954
  var todo = test2.todo;
7840
6955
  var index_default = { AssertionError: Assert.AssertionError, module, test: test2, config: {} };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qunitx",
3
3
  "type": "module",
4
- "version": "1.2.17",
4
+ "version": "1.2.18",
5
5
  "description": "Universal test library — run the same test file in Node.js, Deno, and the browser with QUnit's battle-tested assertion API",
6
6
  "author": "Izel Nakri",
7
7
  "license": "MIT",