chai 5.1.2 → 5.2.0
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/.prettierrc.json +10 -0
- package/chai.js +520 -220
- package/eslint.config.js +14 -0
- package/lib/chai/assertion.js +37 -21
- package/lib/chai/config.js +0 -2
- package/lib/chai/core/assertions.js +698 -475
- package/lib/chai/interface/assert.js +425 -248
- package/lib/chai/interface/expect.js +11 -7
- package/lib/chai/interface/should.js +26 -20
- package/lib/chai/utils/addChainableMethod.js +66 -67
- package/lib/chai/utils/addLengthGuard.js +18 -5
- package/lib/chai/utils/addMethod.js +1 -2
- package/lib/chai/utils/addProperty.js +27 -28
- package/lib/chai/utils/expectTypes.js +15 -7
- package/lib/chai/utils/getMessage.js +16 -10
- package/lib/chai/utils/index.js +8 -2
- package/lib/chai/utils/inspect.js +2 -2
- package/lib/chai/utils/isNaN.js +1 -20
- package/lib/chai/utils/isProxyEnabled.js +4 -2
- package/lib/chai/utils/objDisplay.js +7 -6
- package/lib/chai/utils/overwriteChainableMethod.js +10 -9
- package/lib/chai/utils/overwriteMethod.js +4 -5
- package/lib/chai/utils/overwriteProperty.js +38 -39
- package/lib/chai/utils/proxify.js +31 -21
- package/lib/chai/utils/test.js +2 -2
- package/lib/chai/utils/transferFlags.js +7 -2
- package/lib/chai/utils/type-detect.js +1 -1
- package/lib/chai.js +2 -1
- package/package.json +11 -5
- package/lib/chai/utils/getEnumerableProperties.js +0 -25
- package/register-assert.cjs +0 -3
- package/register-expect.cjs +0 -3
- package/register-should.cjs +0 -3
package/eslint.config.js
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import jsdoc from "eslint-plugin-jsdoc";
|
|
2
|
+
import eslintjs from "@eslint/js";
|
|
3
|
+
|
|
4
|
+
const {configs: eslintConfigs} = eslintjs;
|
|
2
5
|
|
|
3
6
|
export default [
|
|
4
7
|
jsdoc.configs["flat/recommended"],
|
|
8
|
+
eslintConfigs["recommended"],
|
|
5
9
|
{
|
|
10
|
+
languageOptions: {
|
|
11
|
+
// if we ever use more globals than this, pull in the `globals` package
|
|
12
|
+
globals: {
|
|
13
|
+
console: false
|
|
14
|
+
}
|
|
15
|
+
},
|
|
6
16
|
rules: {
|
|
7
17
|
"jsdoc/require-param-description": "off",
|
|
8
18
|
"jsdoc/require-returns-description": "off",
|
|
9
19
|
"jsdoc/tag-lines": ["error", "any", { startLines: 1 }],
|
|
20
|
+
"no-unused-vars": ["error", {
|
|
21
|
+
argsIgnorePattern: "^_",
|
|
22
|
+
caughtErrorsIgnorePattern: "^_"
|
|
23
|
+
}]
|
|
10
24
|
},
|
|
11
25
|
},
|
|
12
26
|
];
|
package/lib/chai/assertion.js
CHANGED
|
@@ -49,7 +49,7 @@ import * as util from './utils/index.js';
|
|
|
49
49
|
* @returns {unknown}
|
|
50
50
|
* @private
|
|
51
51
|
*/
|
|
52
|
-
export function Assertion
|
|
52
|
+
export function Assertion(obj, msg, ssfi, lockSsfi) {
|
|
53
53
|
util.flag(this, 'ssfi', ssfi || Assertion);
|
|
54
54
|
util.flag(this, 'lockSsfi', lockSsfi);
|
|
55
55
|
util.flag(this, 'object', obj);
|
|
@@ -60,23 +60,31 @@ export function Assertion (obj, msg, ssfi, lockSsfi) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
Object.defineProperty(Assertion, 'includeStack', {
|
|
63
|
-
get: function() {
|
|
64
|
-
console.warn(
|
|
63
|
+
get: function () {
|
|
64
|
+
console.warn(
|
|
65
|
+
'Assertion.includeStack is deprecated, use chai.config.includeStack instead.'
|
|
66
|
+
);
|
|
65
67
|
return config.includeStack;
|
|
66
68
|
},
|
|
67
|
-
set: function(value) {
|
|
68
|
-
console.warn(
|
|
69
|
+
set: function (value) {
|
|
70
|
+
console.warn(
|
|
71
|
+
'Assertion.includeStack is deprecated, use chai.config.includeStack instead.'
|
|
72
|
+
);
|
|
69
73
|
config.includeStack = value;
|
|
70
74
|
}
|
|
71
75
|
});
|
|
72
76
|
|
|
73
77
|
Object.defineProperty(Assertion, 'showDiff', {
|
|
74
|
-
get: function() {
|
|
75
|
-
console.warn(
|
|
78
|
+
get: function () {
|
|
79
|
+
console.warn(
|
|
80
|
+
'Assertion.showDiff is deprecated, use chai.config.showDiff instead.'
|
|
81
|
+
);
|
|
76
82
|
return config.showDiff;
|
|
77
83
|
},
|
|
78
|
-
set: function(value) {
|
|
79
|
-
console.warn(
|
|
84
|
+
set: function (value) {
|
|
85
|
+
console.warn(
|
|
86
|
+
'Assertion.showDiff is deprecated, use chai.config.showDiff instead.'
|
|
87
|
+
);
|
|
80
88
|
config.showDiff = value;
|
|
81
89
|
}
|
|
82
90
|
});
|
|
@@ -120,7 +128,14 @@ Assertion.overwriteChainableMethod = function (name, fn, chainingBehavior) {
|
|
|
120
128
|
* @private
|
|
121
129
|
*/
|
|
122
130
|
|
|
123
|
-
Assertion.prototype.assert = function (
|
|
131
|
+
Assertion.prototype.assert = function (
|
|
132
|
+
expr,
|
|
133
|
+
msg,
|
|
134
|
+
negateMsg,
|
|
135
|
+
expected,
|
|
136
|
+
_actual,
|
|
137
|
+
showDiff
|
|
138
|
+
) {
|
|
124
139
|
var ok = util.test(this, arguments);
|
|
125
140
|
if (false !== showDiff) showDiff = true;
|
|
126
141
|
if (undefined === expected && undefined === _actual) showDiff = false;
|
|
@@ -130,9 +145,9 @@ Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual,
|
|
|
130
145
|
msg = util.getMessage(this, arguments);
|
|
131
146
|
var actual = util.getActual(this, arguments);
|
|
132
147
|
var assertionErrorObjectProperties = {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
148
|
+
actual: actual,
|
|
149
|
+
expected: expected,
|
|
150
|
+
showDiff: showDiff
|
|
136
151
|
};
|
|
137
152
|
|
|
138
153
|
var operator = util.getOperator(this, arguments);
|
|
@@ -143,7 +158,8 @@ Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual,
|
|
|
143
158
|
throw new AssertionError(
|
|
144
159
|
msg,
|
|
145
160
|
assertionErrorObjectProperties,
|
|
146
|
-
|
|
161
|
+
config.includeStack ? this.assert : util.flag(this, 'ssfi')
|
|
162
|
+
);
|
|
147
163
|
}
|
|
148
164
|
};
|
|
149
165
|
|
|
@@ -154,11 +170,11 @@ Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual,
|
|
|
154
170
|
*
|
|
155
171
|
* @private
|
|
156
172
|
*/
|
|
157
|
-
Object.defineProperty(Assertion.prototype, '_obj',
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
173
|
+
Object.defineProperty(Assertion.prototype, '_obj', {
|
|
174
|
+
get: function () {
|
|
175
|
+
return util.flag(this, 'object');
|
|
176
|
+
},
|
|
177
|
+
set: function (val) {
|
|
178
|
+
util.flag(this, 'object', val);
|
|
179
|
+
}
|
|
164
180
|
});
|