chai 5.0.3 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/chai.js +94 -220
- package/eslint.config.js +12 -0
- package/lib/chai/assertion.js +30 -31
- package/lib/chai/config.js +18 -24
- package/lib/chai/core/assertions.js +253 -223
- package/lib/chai/interface/assert.js +574 -670
- package/lib/chai/interface/expect.js +12 -7
- package/lib/chai/interface/should.js +43 -40
- package/lib/chai/utils/addChainableMethod.js +6 -11
- package/lib/chai/utils/addLengthGuard.js +3 -3
- package/lib/chai/utils/addMethod.js +5 -6
- package/lib/chai/utils/addProperty.js +5 -6
- package/lib/chai/utils/compareByInspect.js +4 -9
- package/lib/chai/utils/expectTypes.js +7 -8
- package/lib/chai/utils/flag.js +5 -5
- package/lib/chai/utils/getActual.js +3 -3
- package/lib/chai/utils/getEnumerableProperties.js +2 -3
- package/lib/chai/utils/getMessage.js +4 -8
- package/lib/chai/utils/getOperator.js +8 -4
- package/lib/chai/utils/getOwnEnumerableProperties.js +2 -7
- package/lib/chai/utils/getOwnEnumerablePropertySymbols.js +2 -3
- package/lib/chai/utils/getProperties.js +5 -3
- package/lib/chai/utils/index.js +42 -109
- package/lib/chai/utils/inspect.js +5 -4
- package/lib/chai/utils/isNaN.js +3 -3
- package/lib/chai/utils/isProxyEnabled.js +1 -1
- package/lib/chai/utils/objDisplay.js +2 -7
- package/lib/chai/utils/overwriteChainableMethod.js +7 -8
- package/lib/chai/utils/overwriteMethod.js +10 -11
- package/lib/chai/utils/overwriteProperty.js +10 -12
- package/lib/chai/utils/proxify.js +9 -9
- package/lib/chai/utils/test.js +3 -7
- package/lib/chai/utils/transferFlags.js +4 -6
- package/lib/chai/utils/type-detect.js +4 -0
- package/lib/chai.js +9 -31
- package/package.json +6 -3
- package/web-test-runner.config.js +4 -1
package/lib/chai/config.js
CHANGED
|
@@ -9,10 +9,9 @@ export const config = {
|
|
|
9
9
|
*
|
|
10
10
|
* chai.config.includeStack = true; // enable stack on error
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @
|
|
12
|
+
* @param {boolean}
|
|
13
|
+
* @public
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
15
|
includeStack: false,
|
|
17
16
|
|
|
18
17
|
/**
|
|
@@ -24,10 +23,9 @@ export const config = {
|
|
|
24
23
|
* will be true when the assertion has requested a diff
|
|
25
24
|
* be shown.
|
|
26
25
|
*
|
|
27
|
-
* @param {
|
|
28
|
-
* @
|
|
26
|
+
* @param {boolean}
|
|
27
|
+
* @public
|
|
29
28
|
*/
|
|
30
|
-
|
|
31
29
|
showDiff: true,
|
|
32
30
|
|
|
33
31
|
/**
|
|
@@ -46,10 +44,9 @@ export const config = {
|
|
|
46
44
|
*
|
|
47
45
|
* chai.config.truncateThreshold = 0; // disable truncating
|
|
48
46
|
*
|
|
49
|
-
* @param {
|
|
50
|
-
* @
|
|
47
|
+
* @param {number}
|
|
48
|
+
* @public
|
|
51
49
|
*/
|
|
52
|
-
|
|
53
50
|
truncateThreshold: 40,
|
|
54
51
|
|
|
55
52
|
/**
|
|
@@ -66,10 +63,9 @@ export const config = {
|
|
|
66
63
|
* This feature is automatically disabled regardless of this config value
|
|
67
64
|
* in environments that don't support proxies.
|
|
68
65
|
*
|
|
69
|
-
* @param {
|
|
70
|
-
* @
|
|
66
|
+
* @param {boolean}
|
|
67
|
+
* @public
|
|
71
68
|
*/
|
|
72
|
-
|
|
73
69
|
useProxy: true,
|
|
74
70
|
|
|
75
71
|
/**
|
|
@@ -87,9 +83,8 @@ export const config = {
|
|
|
87
83
|
* chai.config.proxyExcludedKeys = ['then', 'inspect'];
|
|
88
84
|
*
|
|
89
85
|
* @param {Array}
|
|
90
|
-
* @
|
|
86
|
+
* @public
|
|
91
87
|
*/
|
|
92
|
-
|
|
93
88
|
proxyExcludedKeys: ['then', 'catch', 'inspect', 'toJSON'],
|
|
94
89
|
|
|
95
90
|
/**
|
|
@@ -101,20 +96,19 @@ export const config = {
|
|
|
101
96
|
*
|
|
102
97
|
* // use a custom comparator
|
|
103
98
|
* chai.config.deepEqual = (expected, actual) => {
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
99
|
+
* return chai.util.eql(expected, actual, {
|
|
100
|
+
* comparator: (expected, actual) => {
|
|
101
|
+
* // for non number comparison, use the default behavior
|
|
102
|
+
* if(typeof expected !== 'number') return null;
|
|
103
|
+
* // allow a difference of 10 between compared numbers
|
|
104
|
+
* return typeof actual === 'number' && Math.abs(actual - expected) < 10
|
|
105
|
+
* }
|
|
106
|
+
* })
|
|
112
107
|
* };
|
|
113
108
|
*
|
|
114
109
|
* @param {Function}
|
|
115
|
-
* @
|
|
110
|
+
* @public
|
|
116
111
|
*/
|
|
117
|
-
|
|
118
112
|
deepEqual: null
|
|
119
113
|
|
|
120
114
|
};
|