chai 5.0.0-alpha.0 → 5.0.0-alpha.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.
- package/chai.js +137 -200
- package/package.json +5 -14
- package/chai.cjs +0 -4480
- package/index.mjs +0 -14
package/chai.js
CHANGED
|
@@ -29,77 +29,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
mod
|
|
30
30
|
));
|
|
31
31
|
|
|
32
|
-
// node_modules/check-error/index.js
|
|
33
|
-
var require_check_error = __commonJS({
|
|
34
|
-
"node_modules/check-error/index.js"(exports, module) {
|
|
35
|
-
"use strict";
|
|
36
|
-
function compatibleInstance(thrown, errorLike) {
|
|
37
|
-
return errorLike instanceof Error && thrown === errorLike;
|
|
38
|
-
}
|
|
39
|
-
__name(compatibleInstance, "compatibleInstance");
|
|
40
|
-
function compatibleConstructor(thrown, errorLike) {
|
|
41
|
-
if (errorLike instanceof Error) {
|
|
42
|
-
return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor;
|
|
43
|
-
} else if (errorLike.prototype instanceof Error || errorLike === Error) {
|
|
44
|
-
return thrown.constructor === errorLike || thrown instanceof errorLike;
|
|
45
|
-
}
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
__name(compatibleConstructor, "compatibleConstructor");
|
|
49
|
-
function compatibleMessage(thrown, errMatcher) {
|
|
50
|
-
var comparisonString = typeof thrown === "string" ? thrown : thrown.message;
|
|
51
|
-
if (errMatcher instanceof RegExp) {
|
|
52
|
-
return errMatcher.test(comparisonString);
|
|
53
|
-
} else if (typeof errMatcher === "string") {
|
|
54
|
-
return comparisonString.indexOf(errMatcher) !== -1;
|
|
55
|
-
}
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
__name(compatibleMessage, "compatibleMessage");
|
|
59
|
-
var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\(\/]+)/;
|
|
60
|
-
function getFunctionName(constructorFn) {
|
|
61
|
-
var name = "";
|
|
62
|
-
if (typeof constructorFn.name === "undefined") {
|
|
63
|
-
var match = String(constructorFn).match(functionNameMatch);
|
|
64
|
-
if (match) {
|
|
65
|
-
name = match[1];
|
|
66
|
-
}
|
|
67
|
-
} else {
|
|
68
|
-
name = constructorFn.name;
|
|
69
|
-
}
|
|
70
|
-
return name;
|
|
71
|
-
}
|
|
72
|
-
__name(getFunctionName, "getFunctionName");
|
|
73
|
-
function getConstructorName(errorLike) {
|
|
74
|
-
var constructorName = errorLike;
|
|
75
|
-
if (errorLike instanceof Error) {
|
|
76
|
-
constructorName = getFunctionName(errorLike.constructor);
|
|
77
|
-
} else if (typeof errorLike === "function") {
|
|
78
|
-
constructorName = getFunctionName(errorLike).trim() || getFunctionName(new errorLike());
|
|
79
|
-
}
|
|
80
|
-
return constructorName;
|
|
81
|
-
}
|
|
82
|
-
__name(getConstructorName, "getConstructorName");
|
|
83
|
-
function getMessage2(errorLike) {
|
|
84
|
-
var msg = "";
|
|
85
|
-
if (errorLike && errorLike.message) {
|
|
86
|
-
msg = errorLike.message;
|
|
87
|
-
} else if (typeof errorLike === "string") {
|
|
88
|
-
msg = errorLike;
|
|
89
|
-
}
|
|
90
|
-
return msg;
|
|
91
|
-
}
|
|
92
|
-
__name(getMessage2, "getMessage");
|
|
93
|
-
module.exports = {
|
|
94
|
-
compatibleInstance,
|
|
95
|
-
compatibleConstructor,
|
|
96
|
-
compatibleMessage,
|
|
97
|
-
getMessage: getMessage2,
|
|
98
|
-
getConstructorName
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
32
|
// node_modules/type-detect/type-detect.js
|
|
104
33
|
var require_type_detect = __commonJS({
|
|
105
34
|
"node_modules/type-detect/type-detect.js"(exports, module) {
|
|
@@ -1310,113 +1239,6 @@ var require_deep_eql = __commonJS({
|
|
|
1310
1239
|
}
|
|
1311
1240
|
});
|
|
1312
1241
|
|
|
1313
|
-
// node_modules/pathval/index.js
|
|
1314
|
-
var require_pathval = __commonJS({
|
|
1315
|
-
"node_modules/pathval/index.js"(exports, module) {
|
|
1316
|
-
"use strict";
|
|
1317
|
-
function hasProperty2(obj, name) {
|
|
1318
|
-
if (typeof obj === "undefined" || obj === null) {
|
|
1319
|
-
return false;
|
|
1320
|
-
}
|
|
1321
|
-
return name in Object(obj);
|
|
1322
|
-
}
|
|
1323
|
-
__name(hasProperty2, "hasProperty");
|
|
1324
|
-
function parsePath(path) {
|
|
1325
|
-
var str = path.replace(/([^\\])\[/g, "$1.[");
|
|
1326
|
-
var parts = str.match(/(\\\.|[^.]+?)+/g);
|
|
1327
|
-
return parts.map(/* @__PURE__ */ __name(function mapMatches(value) {
|
|
1328
|
-
if (value === "constructor" || value === "__proto__" || value === "prototype") {
|
|
1329
|
-
return {};
|
|
1330
|
-
}
|
|
1331
|
-
var regexp = /^\[(\d+)\]$/;
|
|
1332
|
-
var mArr = regexp.exec(value);
|
|
1333
|
-
var parsed = null;
|
|
1334
|
-
if (mArr) {
|
|
1335
|
-
parsed = { i: parseFloat(mArr[1]) };
|
|
1336
|
-
} else {
|
|
1337
|
-
parsed = { p: value.replace(/\\([.[\]])/g, "$1") };
|
|
1338
|
-
}
|
|
1339
|
-
return parsed;
|
|
1340
|
-
}, "mapMatches"));
|
|
1341
|
-
}
|
|
1342
|
-
__name(parsePath, "parsePath");
|
|
1343
|
-
function internalGetPathValue(obj, parsed, pathDepth) {
|
|
1344
|
-
var temporaryValue = obj;
|
|
1345
|
-
var res = null;
|
|
1346
|
-
pathDepth = typeof pathDepth === "undefined" ? parsed.length : pathDepth;
|
|
1347
|
-
for (var i = 0; i < pathDepth; i++) {
|
|
1348
|
-
var part = parsed[i];
|
|
1349
|
-
if (temporaryValue) {
|
|
1350
|
-
if (typeof part.p === "undefined") {
|
|
1351
|
-
temporaryValue = temporaryValue[part.i];
|
|
1352
|
-
} else {
|
|
1353
|
-
temporaryValue = temporaryValue[part.p];
|
|
1354
|
-
}
|
|
1355
|
-
if (i === pathDepth - 1) {
|
|
1356
|
-
res = temporaryValue;
|
|
1357
|
-
}
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
return res;
|
|
1361
|
-
}
|
|
1362
|
-
__name(internalGetPathValue, "internalGetPathValue");
|
|
1363
|
-
function internalSetPathValue(obj, val, parsed) {
|
|
1364
|
-
var tempObj = obj;
|
|
1365
|
-
var pathDepth = parsed.length;
|
|
1366
|
-
var part = null;
|
|
1367
|
-
for (var i = 0; i < pathDepth; i++) {
|
|
1368
|
-
var propName = null;
|
|
1369
|
-
var propVal = null;
|
|
1370
|
-
part = parsed[i];
|
|
1371
|
-
if (i === pathDepth - 1) {
|
|
1372
|
-
propName = typeof part.p === "undefined" ? part.i : part.p;
|
|
1373
|
-
tempObj[propName] = val;
|
|
1374
|
-
} else if (typeof part.p !== "undefined" && tempObj[part.p]) {
|
|
1375
|
-
tempObj = tempObj[part.p];
|
|
1376
|
-
} else if (typeof part.i !== "undefined" && tempObj[part.i]) {
|
|
1377
|
-
tempObj = tempObj[part.i];
|
|
1378
|
-
} else {
|
|
1379
|
-
var next = parsed[i + 1];
|
|
1380
|
-
propName = typeof part.p === "undefined" ? part.i : part.p;
|
|
1381
|
-
propVal = typeof next.p === "undefined" ? [] : {};
|
|
1382
|
-
tempObj[propName] = propVal;
|
|
1383
|
-
tempObj = tempObj[propName];
|
|
1384
|
-
}
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
__name(internalSetPathValue, "internalSetPathValue");
|
|
1388
|
-
function getPathInfo2(obj, path) {
|
|
1389
|
-
var parsed = parsePath(path);
|
|
1390
|
-
var last = parsed[parsed.length - 1];
|
|
1391
|
-
var info = {
|
|
1392
|
-
parent: parsed.length > 1 ? internalGetPathValue(obj, parsed, parsed.length - 1) : obj,
|
|
1393
|
-
name: last.p || last.i,
|
|
1394
|
-
value: internalGetPathValue(obj, parsed)
|
|
1395
|
-
};
|
|
1396
|
-
info.exists = hasProperty2(info.parent, info.name);
|
|
1397
|
-
return info;
|
|
1398
|
-
}
|
|
1399
|
-
__name(getPathInfo2, "getPathInfo");
|
|
1400
|
-
function getPathValue(obj, path) {
|
|
1401
|
-
var info = getPathInfo2(obj, path);
|
|
1402
|
-
return info.value;
|
|
1403
|
-
}
|
|
1404
|
-
__name(getPathValue, "getPathValue");
|
|
1405
|
-
function setPathValue(obj, path, val) {
|
|
1406
|
-
var parsed = parsePath(path);
|
|
1407
|
-
internalSetPathValue(obj, val, parsed);
|
|
1408
|
-
return obj;
|
|
1409
|
-
}
|
|
1410
|
-
__name(setPathValue, "setPathValue");
|
|
1411
|
-
module.exports = {
|
|
1412
|
-
hasProperty: hasProperty2,
|
|
1413
|
-
getPathInfo: getPathInfo2,
|
|
1414
|
-
getPathValue,
|
|
1415
|
-
setPathValue
|
|
1416
|
-
};
|
|
1417
|
-
}
|
|
1418
|
-
});
|
|
1419
|
-
|
|
1420
1242
|
// lib/chai/utils/index.js
|
|
1421
1243
|
var utils_exports = {};
|
|
1422
1244
|
__export(utils_exports, {
|
|
@@ -1424,19 +1246,19 @@ __export(utils_exports, {
|
|
|
1424
1246
|
addLengthGuard: () => addLengthGuard,
|
|
1425
1247
|
addMethod: () => addMethod,
|
|
1426
1248
|
addProperty: () => addProperty,
|
|
1427
|
-
checkError: () =>
|
|
1249
|
+
checkError: () => check_error_exports,
|
|
1428
1250
|
compareByInspect: () => compareByInspect,
|
|
1429
1251
|
eql: () => import_deep_eql.default,
|
|
1430
1252
|
expectTypes: () => expectTypes,
|
|
1431
1253
|
flag: () => flag,
|
|
1432
1254
|
getActual: () => getActual,
|
|
1433
|
-
getMessage: () =>
|
|
1255
|
+
getMessage: () => getMessage2,
|
|
1434
1256
|
getName: () => getName,
|
|
1435
1257
|
getOperator: () => getOperator,
|
|
1436
1258
|
getOwnEnumerableProperties: () => getOwnEnumerableProperties,
|
|
1437
1259
|
getOwnEnumerablePropertySymbols: () => getOwnEnumerablePropertySymbols,
|
|
1438
|
-
getPathInfo: () =>
|
|
1439
|
-
hasProperty: () =>
|
|
1260
|
+
getPathInfo: () => getPathInfo,
|
|
1261
|
+
hasProperty: () => hasProperty,
|
|
1440
1262
|
inspect: () => inspect,
|
|
1441
1263
|
isNaN: () => isNaN,
|
|
1442
1264
|
isProxyEnabled: () => isProxyEnabled,
|
|
@@ -1449,7 +1271,63 @@ __export(utils_exports, {
|
|
|
1449
1271
|
transferFlags: () => transferFlags,
|
|
1450
1272
|
type: () => import_type_detect3.default
|
|
1451
1273
|
});
|
|
1452
|
-
|
|
1274
|
+
|
|
1275
|
+
// node_modules/check-error/index.js
|
|
1276
|
+
var check_error_exports = {};
|
|
1277
|
+
__export(check_error_exports, {
|
|
1278
|
+
compatibleConstructor: () => compatibleConstructor,
|
|
1279
|
+
compatibleInstance: () => compatibleInstance,
|
|
1280
|
+
compatibleMessage: () => compatibleMessage,
|
|
1281
|
+
getConstructorName: () => getConstructorName,
|
|
1282
|
+
getMessage: () => getMessage
|
|
1283
|
+
});
|
|
1284
|
+
function compatibleInstance(thrown, errorLike) {
|
|
1285
|
+
return errorLike instanceof Error && thrown === errorLike;
|
|
1286
|
+
}
|
|
1287
|
+
__name(compatibleInstance, "compatibleInstance");
|
|
1288
|
+
function compatibleConstructor(thrown, errorLike) {
|
|
1289
|
+
if (errorLike instanceof Error) {
|
|
1290
|
+
return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor;
|
|
1291
|
+
} else if (errorLike.prototype instanceof Error || errorLike === Error) {
|
|
1292
|
+
return thrown.constructor === errorLike || thrown instanceof errorLike;
|
|
1293
|
+
}
|
|
1294
|
+
return false;
|
|
1295
|
+
}
|
|
1296
|
+
__name(compatibleConstructor, "compatibleConstructor");
|
|
1297
|
+
function compatibleMessage(thrown, errMatcher) {
|
|
1298
|
+
const comparisonString = typeof thrown === "string" ? thrown : thrown.message;
|
|
1299
|
+
if (errMatcher instanceof RegExp) {
|
|
1300
|
+
return errMatcher.test(comparisonString);
|
|
1301
|
+
} else if (typeof errMatcher === "string") {
|
|
1302
|
+
return comparisonString.indexOf(errMatcher) !== -1;
|
|
1303
|
+
}
|
|
1304
|
+
return false;
|
|
1305
|
+
}
|
|
1306
|
+
__name(compatibleMessage, "compatibleMessage");
|
|
1307
|
+
function getConstructorName(errorLike) {
|
|
1308
|
+
let constructorName = errorLike;
|
|
1309
|
+
if (errorLike instanceof Error) {
|
|
1310
|
+
constructorName = errorLike.constructor.name;
|
|
1311
|
+
} else if (typeof errorLike === "function") {
|
|
1312
|
+
constructorName = errorLike.name;
|
|
1313
|
+
if (constructorName === "") {
|
|
1314
|
+
const newConstructorName = new errorLike().name;
|
|
1315
|
+
constructorName = newConstructorName || constructorName;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
return constructorName;
|
|
1319
|
+
}
|
|
1320
|
+
__name(getConstructorName, "getConstructorName");
|
|
1321
|
+
function getMessage(errorLike) {
|
|
1322
|
+
let msg = "";
|
|
1323
|
+
if (errorLike && errorLike.message) {
|
|
1324
|
+
msg = errorLike.message;
|
|
1325
|
+
} else if (typeof errorLike === "string") {
|
|
1326
|
+
msg = errorLike;
|
|
1327
|
+
}
|
|
1328
|
+
return msg;
|
|
1329
|
+
}
|
|
1330
|
+
__name(getMessage, "getMessage");
|
|
1453
1331
|
|
|
1454
1332
|
// lib/chai/utils/flag.js
|
|
1455
1333
|
function flag(obj, key, value) {
|
|
@@ -1630,7 +1508,7 @@ function objDisplay(obj) {
|
|
|
1630
1508
|
__name(objDisplay, "objDisplay");
|
|
1631
1509
|
|
|
1632
1510
|
// lib/chai/utils/getMessage.js
|
|
1633
|
-
function
|
|
1511
|
+
function getMessage2(obj, args) {
|
|
1634
1512
|
var negate = flag(obj, "negate"), val = flag(obj, "object"), expected = args[3], actual = getActual(obj, args), msg = negate ? args[2] : args[1], flagMsg = flag(obj, "message");
|
|
1635
1513
|
if (typeof msg === "function")
|
|
1636
1514
|
msg = msg();
|
|
@@ -1644,7 +1522,7 @@ function getMessage(obj, args) {
|
|
|
1644
1522
|
});
|
|
1645
1523
|
return flagMsg ? flagMsg + ": " + msg : msg;
|
|
1646
1524
|
}
|
|
1647
|
-
__name(
|
|
1525
|
+
__name(getMessage2, "getMessage");
|
|
1648
1526
|
|
|
1649
1527
|
// lib/chai/utils/transferFlags.js
|
|
1650
1528
|
function transferFlags(assertion, object, includeAll) {
|
|
@@ -1663,7 +1541,66 @@ __name(transferFlags, "transferFlags");
|
|
|
1663
1541
|
|
|
1664
1542
|
// lib/chai/utils/index.js
|
|
1665
1543
|
var import_deep_eql = __toESM(require_deep_eql(), 1);
|
|
1666
|
-
|
|
1544
|
+
|
|
1545
|
+
// node_modules/pathval/index.js
|
|
1546
|
+
function hasProperty(obj, name) {
|
|
1547
|
+
if (typeof obj === "undefined" || obj === null) {
|
|
1548
|
+
return false;
|
|
1549
|
+
}
|
|
1550
|
+
return name in Object(obj);
|
|
1551
|
+
}
|
|
1552
|
+
__name(hasProperty, "hasProperty");
|
|
1553
|
+
function parsePath(path) {
|
|
1554
|
+
const str = path.replace(/([^\\])\[/g, "$1.[");
|
|
1555
|
+
const parts = str.match(/(\\\.|[^.]+?)+/g);
|
|
1556
|
+
return parts.map((value) => {
|
|
1557
|
+
if (value === "constructor" || value === "__proto__" || value === "prototype") {
|
|
1558
|
+
return {};
|
|
1559
|
+
}
|
|
1560
|
+
const regexp = /^\[(\d+)\]$/;
|
|
1561
|
+
const mArr = regexp.exec(value);
|
|
1562
|
+
let parsed = null;
|
|
1563
|
+
if (mArr) {
|
|
1564
|
+
parsed = { i: parseFloat(mArr[1]) };
|
|
1565
|
+
} else {
|
|
1566
|
+
parsed = { p: value.replace(/\\([.[\]])/g, "$1") };
|
|
1567
|
+
}
|
|
1568
|
+
return parsed;
|
|
1569
|
+
});
|
|
1570
|
+
}
|
|
1571
|
+
__name(parsePath, "parsePath");
|
|
1572
|
+
function internalGetPathValue(obj, parsed, pathDepth) {
|
|
1573
|
+
let temporaryValue = obj;
|
|
1574
|
+
let res = null;
|
|
1575
|
+
pathDepth = typeof pathDepth === "undefined" ? parsed.length : pathDepth;
|
|
1576
|
+
for (let i = 0; i < pathDepth; i++) {
|
|
1577
|
+
const part = parsed[i];
|
|
1578
|
+
if (temporaryValue) {
|
|
1579
|
+
if (typeof part.p === "undefined") {
|
|
1580
|
+
temporaryValue = temporaryValue[part.i];
|
|
1581
|
+
} else {
|
|
1582
|
+
temporaryValue = temporaryValue[part.p];
|
|
1583
|
+
}
|
|
1584
|
+
if (i === pathDepth - 1) {
|
|
1585
|
+
res = temporaryValue;
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
return res;
|
|
1590
|
+
}
|
|
1591
|
+
__name(internalGetPathValue, "internalGetPathValue");
|
|
1592
|
+
function getPathInfo(obj, path) {
|
|
1593
|
+
const parsed = parsePath(path);
|
|
1594
|
+
const last = parsed[parsed.length - 1];
|
|
1595
|
+
const info = {
|
|
1596
|
+
parent: parsed.length > 1 ? internalGetPathValue(obj, parsed, parsed.length - 1) : obj,
|
|
1597
|
+
name: last.p || last.i,
|
|
1598
|
+
value: internalGetPathValue(obj, parsed)
|
|
1599
|
+
};
|
|
1600
|
+
info.exists = hasProperty(info.parent, info.name);
|
|
1601
|
+
return info;
|
|
1602
|
+
}
|
|
1603
|
+
__name(getPathInfo, "getPathInfo");
|
|
1667
1604
|
|
|
1668
1605
|
// lib/chai/assertion.js
|
|
1669
1606
|
var import_assertion_error2 = __toESM(require_assertion_error(), 1);
|
|
@@ -1722,7 +1659,7 @@ Assertion.prototype.assert = function(expr, msg, negateMsg, expected, _actual, s
|
|
|
1722
1659
|
if (true !== config.showDiff)
|
|
1723
1660
|
showDiff = false;
|
|
1724
1661
|
if (!ok) {
|
|
1725
|
-
msg =
|
|
1662
|
+
msg = getMessage2(this, arguments);
|
|
1726
1663
|
var actual = getActual(this, arguments);
|
|
1727
1664
|
var assertionErrorObjectProperties = {
|
|
1728
1665
|
actual,
|
|
@@ -2264,7 +2201,7 @@ function include(val, msg) {
|
|
|
2264
2201
|
try {
|
|
2265
2202
|
propAssertion.property(prop, val[prop]);
|
|
2266
2203
|
} catch (err) {
|
|
2267
|
-
if (!
|
|
2204
|
+
if (!check_error_exports.compatibleConstructor(err, import_assertion_error3.default)) {
|
|
2268
2205
|
throw err;
|
|
2269
2206
|
}
|
|
2270
2207
|
if (firstErr === null)
|
|
@@ -2732,7 +2669,7 @@ function assertProperty(name, val, msg) {
|
|
|
2732
2669
|
ssfi
|
|
2733
2670
|
);
|
|
2734
2671
|
}
|
|
2735
|
-
var isDeep = flag2(this, "deep"), negate = flag2(this, "negate"), pathInfo = isNested ?
|
|
2672
|
+
var isDeep = flag2(this, "deep"), negate = flag2(this, "negate"), pathInfo = isNested ? getPathInfo(obj, name) : null, value = isNested ? pathInfo.value : obj[name];
|
|
2736
2673
|
var descriptor = "";
|
|
2737
2674
|
if (isDeep)
|
|
2738
2675
|
descriptor += "deep ";
|
|
@@ -2747,7 +2684,7 @@ function assertProperty(name, val, msg) {
|
|
|
2747
2684
|
else if (isNested)
|
|
2748
2685
|
hasProperty2 = pathInfo.exists;
|
|
2749
2686
|
else
|
|
2750
|
-
hasProperty2 =
|
|
2687
|
+
hasProperty2 = hasProperty(obj, name);
|
|
2751
2688
|
if (!negate || arguments.length === 1) {
|
|
2752
2689
|
this.assert(
|
|
2753
2690
|
hasProperty2,
|
|
@@ -2976,19 +2913,19 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
2976
2913
|
if (errorLike instanceof Error) {
|
|
2977
2914
|
errorLikeString = "#{exp}";
|
|
2978
2915
|
} else if (errorLike) {
|
|
2979
|
-
errorLikeString =
|
|
2916
|
+
errorLikeString = check_error_exports.getConstructorName(errorLike);
|
|
2980
2917
|
}
|
|
2981
2918
|
this.assert(
|
|
2982
2919
|
caughtErr,
|
|
2983
2920
|
"expected #{this} to throw " + errorLikeString,
|
|
2984
2921
|
"expected #{this} to not throw an error but #{act} was thrown",
|
|
2985
2922
|
errorLike && errorLike.toString(),
|
|
2986
|
-
caughtErr instanceof Error ? caughtErr.toString() : typeof caughtErr === "string" ? caughtErr : caughtErr &&
|
|
2923
|
+
caughtErr instanceof Error ? caughtErr.toString() : typeof caughtErr === "string" ? caughtErr : caughtErr && check_error_exports.getConstructorName(caughtErr)
|
|
2987
2924
|
);
|
|
2988
2925
|
}
|
|
2989
2926
|
if (errorLike && caughtErr) {
|
|
2990
2927
|
if (errorLike instanceof Error) {
|
|
2991
|
-
var isCompatibleInstance =
|
|
2928
|
+
var isCompatibleInstance = check_error_exports.compatibleInstance(caughtErr, errorLike);
|
|
2992
2929
|
if (isCompatibleInstance === negate) {
|
|
2993
2930
|
if (everyArgIsDefined && negate) {
|
|
2994
2931
|
errorLikeFail = true;
|
|
@@ -3003,7 +2940,7 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
3003
2940
|
}
|
|
3004
2941
|
}
|
|
3005
2942
|
}
|
|
3006
|
-
var isCompatibleConstructor =
|
|
2943
|
+
var isCompatibleConstructor = check_error_exports.compatibleConstructor(caughtErr, errorLike);
|
|
3007
2944
|
if (isCompatibleConstructor === negate) {
|
|
3008
2945
|
if (everyArgIsDefined && negate) {
|
|
3009
2946
|
errorLikeFail = true;
|
|
@@ -3012,8 +2949,8 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
3012
2949
|
negate,
|
|
3013
2950
|
"expected #{this} to throw #{exp} but #{act} was thrown",
|
|
3014
2951
|
"expected #{this} to not throw #{exp}" + (caughtErr ? " but #{act} was thrown" : ""),
|
|
3015
|
-
errorLike instanceof Error ? errorLike.toString() : errorLike &&
|
|
3016
|
-
caughtErr instanceof Error ? caughtErr.toString() : caughtErr &&
|
|
2952
|
+
errorLike instanceof Error ? errorLike.toString() : errorLike && check_error_exports.getConstructorName(errorLike),
|
|
2953
|
+
caughtErr instanceof Error ? caughtErr.toString() : caughtErr && check_error_exports.getConstructorName(caughtErr)
|
|
3017
2954
|
);
|
|
3018
2955
|
}
|
|
3019
2956
|
}
|
|
@@ -3023,7 +2960,7 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
3023
2960
|
if (errMsgMatcher instanceof RegExp) {
|
|
3024
2961
|
placeholder = "matching";
|
|
3025
2962
|
}
|
|
3026
|
-
var isCompatibleMessage =
|
|
2963
|
+
var isCompatibleMessage = check_error_exports.compatibleMessage(caughtErr, errMsgMatcher);
|
|
3027
2964
|
if (isCompatibleMessage === negate) {
|
|
3028
2965
|
if (everyArgIsDefined && negate) {
|
|
3029
2966
|
errMsgMatcherFail = true;
|
|
@@ -3033,7 +2970,7 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
3033
2970
|
"expected #{this} to throw error " + placeholder + " #{exp} but got #{act}",
|
|
3034
2971
|
"expected #{this} to throw error not " + placeholder + " #{exp}",
|
|
3035
2972
|
errMsgMatcher,
|
|
3036
|
-
|
|
2973
|
+
check_error_exports.getMessage(caughtErr)
|
|
3037
2974
|
);
|
|
3038
2975
|
}
|
|
3039
2976
|
}
|
|
@@ -3043,8 +2980,8 @@ function assertThrows(errorLike, errMsgMatcher, msg) {
|
|
|
3043
2980
|
negate,
|
|
3044
2981
|
"expected #{this} to throw #{exp} but #{act} was thrown",
|
|
3045
2982
|
"expected #{this} to not throw #{exp}" + (caughtErr ? " but #{act} was thrown" : ""),
|
|
3046
|
-
errorLike instanceof Error ? errorLike.toString() : errorLike &&
|
|
3047
|
-
caughtErr instanceof Error ? caughtErr.toString() : caughtErr &&
|
|
2983
|
+
errorLike instanceof Error ? errorLike.toString() : errorLike && check_error_exports.getConstructorName(errorLike),
|
|
2984
|
+
caughtErr instanceof Error ? caughtErr.toString() : caughtErr && check_error_exports.getConstructorName(caughtErr)
|
|
3048
2985
|
);
|
|
3049
2986
|
}
|
|
3050
2987
|
flag2(this, "object", caughtErr);
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"Veselin Todorov <hi@vesln.com>",
|
|
19
19
|
"John Firebaugh <john.firebaugh@gmail.com>"
|
|
20
20
|
],
|
|
21
|
-
"version": "5.0.0-alpha.
|
|
21
|
+
"version": "5.0.0-alpha.1",
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
24
24
|
"url": "https://github.com/chaijs/chai"
|
|
@@ -27,22 +27,13 @@
|
|
|
27
27
|
"url": "https://github.com/chaijs/chai/issues"
|
|
28
28
|
},
|
|
29
29
|
"main": "./chai.js",
|
|
30
|
-
"exports": {
|
|
31
|
-
".": {
|
|
32
|
-
"require": "./chai.cjs",
|
|
33
|
-
"import": "./chai.js"
|
|
34
|
-
},
|
|
35
|
-
"./*": "./*"
|
|
36
|
-
},
|
|
37
30
|
"scripts": {
|
|
38
31
|
"prebuild": "npm run clean",
|
|
39
|
-
"build": "npm run build:
|
|
40
|
-
"build:cjs": "esbuild --bundle --format=cjs --keep-names --outfile=chai.cjs index.js",
|
|
32
|
+
"build": "npm run build:esm",
|
|
41
33
|
"build:esm": "esbuild --bundle --format=esm --keep-names --outfile=chai.js index.js",
|
|
42
34
|
"pretest": "npm run build",
|
|
43
|
-
"test": "npm run test-node && npm run test-
|
|
35
|
+
"test": "npm run test-node && npm run test-chrome",
|
|
44
36
|
"test-node": "mocha --require ./test/bootstrap/index.js --reporter dot test/*.js",
|
|
45
|
-
"test-cjs": "mocha --require ./test/bootstrap/index.js --reporter dot test/*.cjs",
|
|
46
37
|
"test-chrome": "karma start karma.conf.cjs --single-run --browsers HeadlessChrome",
|
|
47
38
|
"test-firefox": "karma start karma.conf.cjs --browsers Firefox",
|
|
48
39
|
"test-cov": "istanbul cover ./node_modules/.bin/_mocha -- --require ./test/bootstrap/index.js test/*.js",
|
|
@@ -53,10 +44,10 @@
|
|
|
53
44
|
},
|
|
54
45
|
"dependencies": {
|
|
55
46
|
"assertion-error": "^1.1.0",
|
|
56
|
-
"check-error": "^
|
|
47
|
+
"check-error": "^2.0.0",
|
|
57
48
|
"deep-eql": "^4.1.2",
|
|
58
49
|
"loupe": "^2.3.1",
|
|
59
|
-
"pathval": "^
|
|
50
|
+
"pathval": "^2.0.0",
|
|
60
51
|
"type-detect": "^4.0.5"
|
|
61
52
|
},
|
|
62
53
|
"devDependencies": {
|