chai 5.0.3 → 5.1.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/chai.js +26 -178
- package/lib/chai/assertion.js +2 -3
- package/lib/chai/core/assertions.js +38 -4
- package/lib/chai/interface/assert.js +250 -355
- package/lib/chai/interface/expect.js +5 -5
- package/lib/chai/interface/should.js +13 -20
- package/lib/chai/utils/addChainableMethod.js +1 -5
- package/lib/chai/utils/compareByInspect.js +0 -4
- package/lib/chai/utils/getMessage.js +0 -4
- package/lib/chai/utils/getOwnEnumerableProperties.js +0 -4
- package/lib/chai/utils/index.js +28 -111
- package/lib/chai/utils/objDisplay.js +0 -4
- package/lib/chai/utils/test.js +0 -4
- package/lib/chai.js +7 -29
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ function expect(val, message) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export {expect};
|
|
16
|
+
|
|
16
17
|
/**
|
|
17
18
|
* ### .fail([message])
|
|
18
19
|
* ### .fail(actual, expected, [message], [operator])
|
|
@@ -27,14 +28,13 @@ export {expect};
|
|
|
27
28
|
* expect.fail(1, 2, undefined, ">");
|
|
28
29
|
*
|
|
29
30
|
* @name fail
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {
|
|
31
|
+
* @param {unknown} actual
|
|
32
|
+
* @param {unknown} expected
|
|
32
33
|
* @param {String} message
|
|
33
34
|
* @param {String} operator
|
|
34
|
-
* @namespace
|
|
35
|
-
* @
|
|
35
|
+
* @namespace expect
|
|
36
|
+
* @public
|
|
36
37
|
*/
|
|
37
|
-
|
|
38
38
|
expect.fail = function (actual, expected, message, operator) {
|
|
39
39
|
if (arguments.length < 2) {
|
|
40
40
|
message = actual;
|
|
@@ -57,14 +57,13 @@ function loadShould () {
|
|
|
57
57
|
*
|
|
58
58
|
*
|
|
59
59
|
* @name fail
|
|
60
|
-
* @param {
|
|
61
|
-
* @param {
|
|
60
|
+
* @param {unknown} actual
|
|
61
|
+
* @param {unknown} expected
|
|
62
62
|
* @param {String} message
|
|
63
63
|
* @param {String} operator
|
|
64
64
|
* @namespace BDD
|
|
65
|
-
* @
|
|
65
|
+
* @public
|
|
66
66
|
*/
|
|
67
|
-
|
|
68
67
|
should.fail = function (actual, expected, message, operator) {
|
|
69
68
|
if (arguments.length < 2) {
|
|
70
69
|
message = actual;
|
|
@@ -87,13 +86,12 @@ function loadShould () {
|
|
|
87
86
|
* should.equal(3, '3', '== coerces values to strings');
|
|
88
87
|
*
|
|
89
88
|
* @name equal
|
|
90
|
-
* @param {
|
|
91
|
-
* @param {
|
|
89
|
+
* @param {unknown} actual
|
|
90
|
+
* @param {unknown} expected
|
|
92
91
|
* @param {String} message
|
|
93
92
|
* @namespace Should
|
|
94
|
-
* @
|
|
93
|
+
* @public
|
|
95
94
|
*/
|
|
96
|
-
|
|
97
95
|
should.equal = function (val1, val2, msg) {
|
|
98
96
|
new Assertion(val1, msg).to.equal(val2);
|
|
99
97
|
};
|
|
@@ -119,9 +117,8 @@ function loadShould () {
|
|
|
119
117
|
* @param {String} message
|
|
120
118
|
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
|
121
119
|
* @namespace Should
|
|
122
|
-
* @
|
|
120
|
+
* @public
|
|
123
121
|
*/
|
|
124
|
-
|
|
125
122
|
should.Throw = function (fn, errt, errs, msg) {
|
|
126
123
|
new Assertion(fn, msg).to.Throw(errt, errs);
|
|
127
124
|
};
|
|
@@ -137,9 +134,8 @@ function loadShould () {
|
|
|
137
134
|
*
|
|
138
135
|
* @name exist
|
|
139
136
|
* @namespace Should
|
|
140
|
-
* @
|
|
137
|
+
* @public
|
|
141
138
|
*/
|
|
142
|
-
|
|
143
139
|
should.exist = function (val, msg) {
|
|
144
140
|
new Assertion(val, msg).to.exist;
|
|
145
141
|
}
|
|
@@ -155,13 +151,12 @@ function loadShould () {
|
|
|
155
151
|
* should.not.equal(3, 4, 'these numbers are not equal');
|
|
156
152
|
*
|
|
157
153
|
* @name not.equal
|
|
158
|
-
* @param {
|
|
159
|
-
* @param {
|
|
154
|
+
* @param {unknown} actual
|
|
155
|
+
* @param {unknown} expected
|
|
160
156
|
* @param {String} message
|
|
161
157
|
* @namespace Should
|
|
162
|
-
* @
|
|
158
|
+
* @public
|
|
163
159
|
*/
|
|
164
|
-
|
|
165
160
|
should.not.equal = function (val1, val2, msg) {
|
|
166
161
|
new Assertion(val1, msg).to.not.equal(val2);
|
|
167
162
|
};
|
|
@@ -183,9 +178,8 @@ function loadShould () {
|
|
|
183
178
|
* @param {String} message
|
|
184
179
|
* @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types
|
|
185
180
|
* @namespace Should
|
|
186
|
-
* @
|
|
181
|
+
* @public
|
|
187
182
|
*/
|
|
188
|
-
|
|
189
183
|
should.not.Throw = function (fn, errt, errs, msg) {
|
|
190
184
|
new Assertion(fn, msg).to.not.Throw(errt, errs);
|
|
191
185
|
};
|
|
@@ -201,9 +195,8 @@ function loadShould () {
|
|
|
201
195
|
*
|
|
202
196
|
* @name not.exist
|
|
203
197
|
* @namespace Should
|
|
204
|
-
* @
|
|
198
|
+
* @public
|
|
205
199
|
*/
|
|
206
|
-
|
|
207
200
|
should.not.exist = function (val, msg) {
|
|
208
201
|
new Assertion(val, msg).to.not.exist;
|
|
209
202
|
}
|
|
@@ -4,17 +4,13 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
/*!
|
|
8
|
-
* Module dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
7
|
import {Assertion} from '../assertion.js';
|
|
12
8
|
import {addLengthGuard} from './addLengthGuard.js';
|
|
13
9
|
import {flag} from './flag.js';
|
|
14
10
|
import {proxify} from './proxify.js';
|
|
15
11
|
import {transferFlags} from './transferFlags.js';
|
|
16
12
|
|
|
17
|
-
|
|
13
|
+
/**
|
|
18
14
|
* Module variables
|
|
19
15
|
*/
|
|
20
16
|
|
package/lib/chai/utils/index.js
CHANGED
|
@@ -4,171 +4,88 @@
|
|
|
4
4
|
* MIT Licensed
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
* Dependencies that are used for multiple exports are required here only once
|
|
9
|
-
*/
|
|
10
|
-
|
|
7
|
+
// Dependencies that are used for multiple exports are required here only once
|
|
11
8
|
import * as checkError from 'check-error';
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
* test utility
|
|
15
|
-
*/
|
|
16
|
-
|
|
10
|
+
// test utility
|
|
17
11
|
export {test} from './test.js';
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
* type utility
|
|
21
|
-
*/
|
|
22
|
-
|
|
13
|
+
// type utility
|
|
23
14
|
export {type} from './type-detect.js';
|
|
24
15
|
|
|
25
|
-
|
|
26
|
-
* expectTypes utility
|
|
27
|
-
*/
|
|
16
|
+
// expectTypes utility
|
|
28
17
|
export {expectTypes} from './expectTypes.js';
|
|
29
18
|
|
|
30
|
-
|
|
31
|
-
* message utility
|
|
32
|
-
*/
|
|
33
|
-
|
|
19
|
+
// message utility
|
|
34
20
|
export {getMessage} from './getMessage.js';
|
|
35
21
|
|
|
36
|
-
|
|
37
|
-
* actual utility
|
|
38
|
-
*/
|
|
39
|
-
|
|
22
|
+
// actual utility
|
|
40
23
|
export {getActual} from './getActual.js';
|
|
41
24
|
|
|
42
|
-
|
|
43
|
-
* Inspect util
|
|
44
|
-
*/
|
|
45
|
-
|
|
25
|
+
// Inspect util
|
|
46
26
|
export {inspect} from './inspect.js';
|
|
47
27
|
|
|
48
|
-
|
|
49
|
-
* Object Display util
|
|
50
|
-
*/
|
|
51
|
-
|
|
28
|
+
// Object Display util
|
|
52
29
|
export {objDisplay} from './objDisplay.js';
|
|
53
30
|
|
|
54
|
-
|
|
55
|
-
* Flag utility
|
|
56
|
-
*/
|
|
57
|
-
|
|
31
|
+
// Flag utility
|
|
58
32
|
export {flag} from './flag.js';
|
|
59
33
|
|
|
60
|
-
|
|
61
|
-
* Flag transferring utility
|
|
62
|
-
*/
|
|
63
|
-
|
|
34
|
+
// Flag transferring utility
|
|
64
35
|
export {transferFlags} from './transferFlags.js';
|
|
65
36
|
|
|
66
|
-
|
|
67
|
-
* Deep equal utility
|
|
68
|
-
*/
|
|
69
|
-
|
|
37
|
+
// Deep equal utility
|
|
70
38
|
export {default as eql} from 'deep-eql';
|
|
71
39
|
|
|
72
|
-
|
|
73
|
-
* Deep path info
|
|
74
|
-
*/
|
|
75
|
-
|
|
40
|
+
// Deep path info
|
|
76
41
|
export {getPathInfo, hasProperty} from 'pathval';
|
|
77
42
|
|
|
78
|
-
|
|
79
|
-
* Function name
|
|
80
|
-
*/
|
|
81
|
-
|
|
43
|
+
// Function name
|
|
82
44
|
export function getName(fn) {
|
|
83
45
|
return fn.name
|
|
84
46
|
}
|
|
85
47
|
|
|
86
|
-
|
|
87
|
-
* add Property
|
|
88
|
-
*/
|
|
89
|
-
|
|
48
|
+
// add Property
|
|
90
49
|
export {addProperty} from './addProperty.js';
|
|
91
50
|
|
|
92
|
-
|
|
93
|
-
* add Method
|
|
94
|
-
*/
|
|
95
|
-
|
|
51
|
+
// add Method
|
|
96
52
|
export {addMethod} from './addMethod.js';
|
|
97
53
|
|
|
98
|
-
|
|
99
|
-
* overwrite Property
|
|
100
|
-
*/
|
|
101
|
-
|
|
54
|
+
// overwrite Property
|
|
102
55
|
export {overwriteProperty} from './overwriteProperty.js';
|
|
103
56
|
|
|
104
|
-
|
|
105
|
-
* overwrite Method
|
|
106
|
-
*/
|
|
107
|
-
|
|
57
|
+
// overwrite Method
|
|
108
58
|
export {overwriteMethod} from './overwriteMethod.js';
|
|
109
59
|
|
|
110
|
-
|
|
111
|
-
* Add a chainable method
|
|
112
|
-
*/
|
|
113
|
-
|
|
60
|
+
// Add a chainable method
|
|
114
61
|
export {addChainableMethod} from './addChainableMethod.js';
|
|
115
62
|
|
|
116
|
-
|
|
117
|
-
* Overwrite chainable method
|
|
118
|
-
*/
|
|
119
|
-
|
|
63
|
+
// Overwrite chainable method
|
|
120
64
|
export {overwriteChainableMethod} from './overwriteChainableMethod.js';
|
|
121
65
|
|
|
122
|
-
|
|
123
|
-
* Compare by inspect method
|
|
124
|
-
*/
|
|
125
|
-
|
|
66
|
+
// Compare by inspect method
|
|
126
67
|
export {compareByInspect} from './compareByInspect.js';
|
|
127
68
|
|
|
128
|
-
|
|
129
|
-
* Get own enumerable property symbols method
|
|
130
|
-
*/
|
|
131
|
-
|
|
69
|
+
// Get own enumerable property symbols method
|
|
132
70
|
export {getOwnEnumerablePropertySymbols} from './getOwnEnumerablePropertySymbols.js';
|
|
133
71
|
|
|
134
|
-
|
|
135
|
-
* Get own enumerable properties method
|
|
136
|
-
*/
|
|
137
|
-
|
|
72
|
+
// Get own enumerable properties method
|
|
138
73
|
export {getOwnEnumerableProperties} from './getOwnEnumerableProperties.js';
|
|
139
74
|
|
|
140
|
-
|
|
141
|
-
* Checks error against a given set of criteria
|
|
142
|
-
*/
|
|
143
|
-
|
|
75
|
+
// Checks error against a given set of criteria
|
|
144
76
|
export {checkError};
|
|
145
77
|
|
|
146
|
-
|
|
147
|
-
* Proxify util
|
|
148
|
-
*/
|
|
149
|
-
|
|
78
|
+
// Proxify util
|
|
150
79
|
export {proxify} from './proxify.js';
|
|
151
80
|
|
|
152
|
-
|
|
153
|
-
* addLengthGuard util
|
|
154
|
-
*/
|
|
155
|
-
|
|
81
|
+
// addLengthGuard util
|
|
156
82
|
export {addLengthGuard} from './addLengthGuard.js';
|
|
157
83
|
|
|
158
|
-
|
|
159
|
-
* isProxyEnabled helper
|
|
160
|
-
*/
|
|
161
|
-
|
|
84
|
+
// isProxyEnabled helper
|
|
162
85
|
export {isProxyEnabled} from './isProxyEnabled.js';
|
|
163
86
|
|
|
164
|
-
|
|
165
|
-
* isNaN method
|
|
166
|
-
*/
|
|
167
|
-
|
|
87
|
+
// isNaN method
|
|
168
88
|
export {isNaN} from './isNaN.js';
|
|
169
89
|
|
|
170
|
-
|
|
171
|
-
* getOperator method
|
|
172
|
-
*/
|
|
173
|
-
|
|
90
|
+
// getOperator method
|
|
174
91
|
export {getOperator} from './getOperator.js';
|
package/lib/chai/utils/test.js
CHANGED
package/lib/chai.js
CHANGED
|
@@ -15,10 +15,7 @@ import {assert} from './chai/interface/assert.js';
|
|
|
15
15
|
|
|
16
16
|
const used = [];
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
* Assertion Error
|
|
20
|
-
*/
|
|
21
|
-
|
|
18
|
+
// Assertion Error
|
|
22
19
|
export {AssertionError};
|
|
23
20
|
|
|
24
21
|
/**
|
|
@@ -30,7 +27,6 @@ export {AssertionError};
|
|
|
30
27
|
* @returns {this} for chaining
|
|
31
28
|
* @api public
|
|
32
29
|
*/
|
|
33
|
-
|
|
34
30
|
export function use(fn) {
|
|
35
31
|
const exports = {
|
|
36
32
|
AssertionError,
|
|
@@ -50,38 +46,20 @@ export function use(fn) {
|
|
|
50
46
|
return exports;
|
|
51
47
|
};
|
|
52
48
|
|
|
53
|
-
|
|
54
|
-
* Utility Functions
|
|
55
|
-
*/
|
|
56
|
-
|
|
49
|
+
// Utility Functions
|
|
57
50
|
export {util};
|
|
58
51
|
|
|
59
|
-
|
|
60
|
-
* Configuration
|
|
61
|
-
*/
|
|
62
|
-
|
|
52
|
+
// Configuration
|
|
63
53
|
export {config};
|
|
64
54
|
|
|
65
|
-
|
|
66
|
-
* Primary `Assertion` prototype
|
|
67
|
-
*/
|
|
68
|
-
|
|
55
|
+
// Primary `Assertion` prototype
|
|
69
56
|
export * from './chai/assertion.js';
|
|
70
57
|
|
|
71
|
-
|
|
72
|
-
* Expect interface
|
|
73
|
-
*/
|
|
74
|
-
|
|
58
|
+
// Expect interface
|
|
75
59
|
export * from './chai/interface/expect.js';
|
|
76
60
|
|
|
77
|
-
|
|
78
|
-
* Should interface
|
|
79
|
-
*/
|
|
80
|
-
|
|
61
|
+
// Should interface
|
|
81
62
|
export * from './chai/interface/should.js';
|
|
82
63
|
|
|
83
|
-
|
|
84
|
-
* Assert interface
|
|
85
|
-
*/
|
|
86
|
-
|
|
64
|
+
// Assert interface
|
|
87
65
|
export * from './chai/interface/assert.js';
|