@xylabs/vitest-matchers 5.0.94 → 5.0.96
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 +585 -119
- package/package.json +6 -13
package/README.md
CHANGED
|
@@ -1,43 +1,52 @@
|
|
|
1
1
|
# @xylabs/vitest-matchers
|
|
2
2
|
|
|
3
|
-
[![
|
|
3
|
+
[![npm][npm-badge]][npm-link]
|
|
4
|
+
[![license][license-badge]][license-link]
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
[![npm-badge][]][npm-link]
|
|
7
|
-
[![npm-downloads-badge][]][npm-link]
|
|
8
|
-
[![jsdelivr-badge][]][jsdelivr-link]
|
|
9
|
-
[![npm-license-badge][]](LICENSE)
|
|
10
|
-
[![codacy-badge][]][codacy-link]
|
|
11
|
-
[![codeclimate-badge][]][codeclimate-link]
|
|
12
|
-
[![snyk-badge][]][snyk-link]
|
|
13
|
-
[![socket-badge][]][socket-link]
|
|
6
|
+
> Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
14
7
|
|
|
8
|
+
## Install
|
|
15
9
|
|
|
16
|
-
|
|
10
|
+
Using npm:
|
|
17
11
|
|
|
12
|
+
```sh
|
|
13
|
+
npm install {{name}}
|
|
14
|
+
```
|
|
18
15
|
|
|
16
|
+
Using yarn:
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
```sh
|
|
19
|
+
yarn add {{name}}
|
|
20
|
+
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Using pnpm:
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
```sh
|
|
25
|
+
pnpm add {{name}}
|
|
26
|
+
```
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
Using bun:
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
```sh
|
|
31
|
+
bun add {{name}}
|
|
32
|
+
```
|
|
31
33
|
|
|
32
|
-
## Variables
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).
|
|
38
|
+
|
|
39
|
+
## Reference
|
|
40
|
+
|
|
41
|
+
### packages
|
|
37
42
|
|
|
38
|
-
###
|
|
43
|
+
### vitest-matchers
|
|
39
44
|
|
|
40
|
-
|
|
45
|
+
### .temp-typedoc
|
|
46
|
+
|
|
47
|
+
### interfaces
|
|
48
|
+
|
|
49
|
+
### <a id="ExpectationResult"></a>ExpectationResult
|
|
41
50
|
|
|
42
51
|
[**@xylabs/vitest-matchers**](#../README)
|
|
43
52
|
|
|
@@ -47,121 +56,578 @@ Result returned by a custom matcher function.
|
|
|
47
56
|
|
|
48
57
|
## Properties
|
|
49
58
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
### actual?
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
optional actual?: unknown;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The actual value received by the matcher.
|
|
66
|
+
|
|
67
|
+
***
|
|
56
68
|
|
|
57
|
-
###
|
|
69
|
+
### expected?
|
|
58
70
|
|
|
59
|
-
|
|
71
|
+
```ts
|
|
72
|
+
optional expected?: unknown;
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The expected value the matcher compared against.
|
|
76
|
+
|
|
77
|
+
***
|
|
78
|
+
|
|
79
|
+
### message
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
message: () => string;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Returns a human-readable failure or negation message.
|
|
86
|
+
|
|
87
|
+
### Returns
|
|
88
|
+
|
|
89
|
+
`string`
|
|
90
|
+
|
|
91
|
+
***
|
|
92
|
+
|
|
93
|
+
### pass
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
pass: boolean;
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Whether the matcher assertion passed.
|
|
100
|
+
|
|
101
|
+
### variables
|
|
102
|
+
|
|
103
|
+
### <a id="matchers"></a>matchers
|
|
60
104
|
|
|
61
105
|
[**@xylabs/vitest-matchers**](#../README)
|
|
62
106
|
|
|
63
107
|
***
|
|
64
108
|
|
|
65
109
|
```ts
|
|
66
|
-
const matchers:
|
|
67
|
-
toBeArrayOfSize: ExpectationResult;
|
|
68
|
-
toBeArray: ExpectationResult;
|
|
69
|
-
toBeOneOf: ExpectationResult;
|
|
70
|
-
toBeNegative: ExpectationResult;
|
|
71
|
-
toBePositive: ExpectationResult;
|
|
72
|
-
toBeNumber: (received: unknown) => ExpectationResult;
|
|
73
|
-
toBeFunction: (received: unknown) => ExpectationResult;
|
|
74
|
-
toBeString: (received: unknown) => ExpectationResult;
|
|
75
|
-
toBeObject: ExpectationResult;
|
|
76
|
-
toBeInteger: ExpectationResult;
|
|
77
|
-
toBeFalse: ExpectationResult;
|
|
78
|
-
toBeTrue: ExpectationResult;
|
|
79
|
-
toContainAllValues: {
|
|
80
|
-
pass: boolean;
|
|
81
|
-
message: () => string;
|
|
82
|
-
};
|
|
83
|
-
toContainKey: {
|
|
84
|
-
pass: boolean;
|
|
85
|
-
message: () => string;
|
|
86
|
-
};
|
|
87
|
-
toInclude: {
|
|
88
|
-
pass: boolean;
|
|
89
|
-
message: () => string;
|
|
90
|
-
};
|
|
91
|
-
toIncludeAllMembers: ExpectationResult;
|
|
92
|
-
toContainAllKeys: ExpectationResult;
|
|
93
|
-
toContainValues: ExpectationResult;
|
|
94
|
-
toBeEmpty: ExpectationResult;
|
|
95
|
-
toBeValidDate: {
|
|
96
|
-
pass: boolean;
|
|
97
|
-
message: () => string;
|
|
98
|
-
};
|
|
99
|
-
};
|
|
110
|
+
const matchers: object;
|
|
100
111
|
```
|
|
101
112
|
|
|
102
113
|
Collection of custom Vitest matchers extending the built-in `expect` assertions.
|
|
103
114
|
|
|
104
115
|
## Type Declaration
|
|
105
116
|
|
|
106
|
-
|
|
107
|
-
| ------ | ------ | ------ |
|
|
108
|
-
| `toBeArrayOfSize()` | (`received`: `unknown`, `expectedSize`: `number`) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts the received value is an array with the specified length. |
|
|
109
|
-
| `toBeArray()` | (`received`: `unknown`) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts the received value is an array. |
|
|
110
|
-
| `toBeOneOf()` | (`received`: `unknown`, `expected`: `unknown`[]) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts the received value is one of the values in the expected array. |
|
|
111
|
-
| `toBeNegative()` | (`received`: `number`) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts the received number is negative (less than zero). |
|
|
112
|
-
| `toBePositive()` | (`received`: `number`) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts the received number is positive (greater than zero). |
|
|
113
|
-
| <a id="property-tobenumber"></a> `toBeNumber()` | (`received`: `unknown`) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts the received value is of type `number` and not NaN. |
|
|
114
|
-
| <a id="property-tobefunction"></a> `toBeFunction()` | (`received`: `unknown`) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts the received value is of type `function`. |
|
|
115
|
-
| <a id="property-tobestring"></a> `toBeString()` | (`received`: `unknown`) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts the received value is of type `string`. |
|
|
116
|
-
| `toBeObject()` | (`received`: `unknown`) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts the received value is a plain object (not an array or null). |
|
|
117
|
-
| `toBeInteger()` | (`received`: `number`) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts the received number is an integer. |
|
|
118
|
-
| `toBeFalse()` | (`received`: `unknown`) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts the received value is strictly `false`. |
|
|
119
|
-
| `toBeTrue()` | (`received`: `unknown`) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts the received value is strictly `true`. |
|
|
120
|
-
| `toContainAllValues()` | (`received`: `unknown`, `expectedValues`: `unknown`[]) => \{ `pass`: `boolean`; `message`: () => `string`; \} | Asserts that all expected values are present in the received array or object values. |
|
|
121
|
-
| `toContainKey()` | (`received`: `object`, `key`: `string`) => \{ `pass`: `boolean`; `message`: () => `string`; \} | Asserts that the received object contains the specified key. |
|
|
122
|
-
| `toInclude()` | (`received`: `unknown`, `value`: `any`) => \{ `pass`: `boolean`; `message`: () => `string`; \} | Asserts that the received array, string, or object values include the specified value. |
|
|
123
|
-
| `toIncludeAllMembers()` | (`received`: `unknown`[], `expected`: `unknown`[]) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts that the received array includes all members of the expected array. |
|
|
124
|
-
| `toContainAllKeys()` | (`received`: `object`, `expectedKeys`: `string`[]) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts that the received object contains all of the specified keys. |
|
|
125
|
-
| `toContainValues()` | (`received`: `object`, `expectedValues`: `unknown`[]) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts that the received object contains all of the specified values (using deep equality). |
|
|
126
|
-
| `toBeEmpty()` | (`received`: `unknown`) => [`ExpectationResult`](#../interfaces/ExpectationResult) | Asserts the received value is empty (zero-length array/string, empty object, or empty Map/Set). |
|
|
127
|
-
| `toBeValidDate()` | (`received`: `unknown`) => \{ `pass`: `boolean`; `message`: () => `string`; \} | Asserts the received value is a valid Date instance (not an invalid date). |
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js)
|
|
131
|
-
|
|
132
|
-
## Maintainers
|
|
133
|
-
|
|
134
|
-
- [Arie Trouw](https://github.com/arietrouw) ([arietrouw.com](https://arietrouw.com))
|
|
135
|
-
- [Matt Jones](https://github.com/jonesmac)
|
|
136
|
-
- [Joel Carter](https://github.com/JoelBCarter)
|
|
137
|
-
- [Jordan Trouw](https://github.com/jordantrouw)
|
|
117
|
+
### toBeArrayOfSize()
|
|
138
118
|
|
|
139
|
-
|
|
119
|
+
```ts
|
|
120
|
+
toBeArrayOfSize(received, expectedSize): ExpectationResult;
|
|
121
|
+
```
|
|
140
122
|
|
|
141
|
-
|
|
123
|
+
Asserts the received value is an array with the specified length.
|
|
142
124
|
|
|
143
|
-
|
|
125
|
+
### Parameters
|
|
144
126
|
|
|
145
|
-
|
|
127
|
+
#### received
|
|
146
128
|
|
|
147
|
-
|
|
129
|
+
`unknown`
|
|
148
130
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
131
|
+
The value to check.
|
|
132
|
+
|
|
133
|
+
#### expectedSize
|
|
134
|
+
|
|
135
|
+
`number`
|
|
136
|
+
|
|
137
|
+
The expected array length.
|
|
138
|
+
|
|
139
|
+
### Returns
|
|
140
|
+
|
|
141
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
142
|
+
|
|
143
|
+
### toBeArray()
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
toBeArray(received): ExpectationResult;
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Asserts the received value is an array.
|
|
150
|
+
|
|
151
|
+
### Parameters
|
|
152
|
+
|
|
153
|
+
#### received
|
|
154
|
+
|
|
155
|
+
`unknown`
|
|
156
|
+
|
|
157
|
+
The value to check.
|
|
158
|
+
|
|
159
|
+
### Returns
|
|
160
|
+
|
|
161
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
162
|
+
|
|
163
|
+
### toBeOneOf()
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
toBeOneOf(received, expected): ExpectationResult;
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Asserts the received value is one of the values in the expected array.
|
|
170
|
+
|
|
171
|
+
### Parameters
|
|
172
|
+
|
|
173
|
+
#### received
|
|
174
|
+
|
|
175
|
+
`unknown`
|
|
176
|
+
|
|
177
|
+
The value to check.
|
|
178
|
+
|
|
179
|
+
#### expected
|
|
180
|
+
|
|
181
|
+
`unknown`[]
|
|
182
|
+
|
|
183
|
+
The array of acceptable values.
|
|
184
|
+
|
|
185
|
+
### Returns
|
|
186
|
+
|
|
187
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
188
|
+
|
|
189
|
+
### toBeNegative()
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
toBeNegative(received): ExpectationResult;
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Asserts the received number is negative (less than zero).
|
|
196
|
+
|
|
197
|
+
### Parameters
|
|
198
|
+
|
|
199
|
+
#### received
|
|
200
|
+
|
|
201
|
+
`number`
|
|
202
|
+
|
|
203
|
+
The number to check.
|
|
204
|
+
|
|
205
|
+
### Returns
|
|
206
|
+
|
|
207
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
208
|
+
|
|
209
|
+
### toBePositive()
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
toBePositive(received): ExpectationResult;
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Asserts the received number is positive (greater than zero).
|
|
216
|
+
|
|
217
|
+
### Parameters
|
|
218
|
+
|
|
219
|
+
#### received
|
|
220
|
+
|
|
221
|
+
`number`
|
|
222
|
+
|
|
223
|
+
The number to check.
|
|
224
|
+
|
|
225
|
+
### Returns
|
|
226
|
+
|
|
227
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
228
|
+
|
|
229
|
+
### toBeNumber
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
toBeNumber: (received) => ExpectationResult;
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Asserts the received value is of type `number` and not NaN.
|
|
236
|
+
|
|
237
|
+
### Parameters
|
|
238
|
+
|
|
239
|
+
#### received
|
|
240
|
+
|
|
241
|
+
`unknown`
|
|
242
|
+
|
|
243
|
+
The value to check.
|
|
244
|
+
|
|
245
|
+
### Returns
|
|
246
|
+
|
|
247
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
248
|
+
|
|
249
|
+
### toBeFunction
|
|
250
|
+
|
|
251
|
+
```ts
|
|
252
|
+
toBeFunction: (received) => ExpectationResult;
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Asserts the received value is of type `function`.
|
|
256
|
+
|
|
257
|
+
### Parameters
|
|
258
|
+
|
|
259
|
+
#### received
|
|
260
|
+
|
|
261
|
+
`unknown`
|
|
262
|
+
|
|
263
|
+
The value to check.
|
|
264
|
+
|
|
265
|
+
### Returns
|
|
266
|
+
|
|
267
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
268
|
+
|
|
269
|
+
### toBeString
|
|
270
|
+
|
|
271
|
+
```ts
|
|
272
|
+
toBeString: (received) => ExpectationResult;
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Asserts the received value is of type `string`.
|
|
276
|
+
|
|
277
|
+
### Parameters
|
|
278
|
+
|
|
279
|
+
#### received
|
|
280
|
+
|
|
281
|
+
`unknown`
|
|
282
|
+
|
|
283
|
+
The value to check.
|
|
284
|
+
|
|
285
|
+
### Returns
|
|
286
|
+
|
|
287
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
288
|
+
|
|
289
|
+
### toBeObject()
|
|
290
|
+
|
|
291
|
+
```ts
|
|
292
|
+
toBeObject(received): ExpectationResult;
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Asserts the received value is a plain object (not an array or null).
|
|
296
|
+
|
|
297
|
+
### Parameters
|
|
298
|
+
|
|
299
|
+
#### received
|
|
300
|
+
|
|
301
|
+
`unknown`
|
|
302
|
+
|
|
303
|
+
The value to check.
|
|
304
|
+
|
|
305
|
+
### Returns
|
|
306
|
+
|
|
307
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
308
|
+
|
|
309
|
+
### toBeInteger()
|
|
310
|
+
|
|
311
|
+
```ts
|
|
312
|
+
toBeInteger(received): ExpectationResult;
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Asserts the received number is an integer.
|
|
316
|
+
|
|
317
|
+
### Parameters
|
|
318
|
+
|
|
319
|
+
#### received
|
|
320
|
+
|
|
321
|
+
`number`
|
|
322
|
+
|
|
323
|
+
The number to check.
|
|
324
|
+
|
|
325
|
+
### Returns
|
|
326
|
+
|
|
327
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
328
|
+
|
|
329
|
+
### toBeFalse()
|
|
330
|
+
|
|
331
|
+
```ts
|
|
332
|
+
toBeFalse(received): ExpectationResult;
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Asserts the received value is strictly `false`.
|
|
336
|
+
|
|
337
|
+
### Parameters
|
|
338
|
+
|
|
339
|
+
#### received
|
|
340
|
+
|
|
341
|
+
`unknown`
|
|
342
|
+
|
|
343
|
+
The value to check.
|
|
159
344
|
|
|
160
|
-
|
|
161
|
-
[npm-license-badge]: https://img.shields.io/npm/l/@xylabs/vitest-matchers
|
|
345
|
+
### Returns
|
|
162
346
|
|
|
163
|
-
[
|
|
164
|
-
[jsdelivr-link]: https://www.jsdelivr.com/package/npm/@xylabs/vitest-matchers
|
|
347
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
165
348
|
|
|
166
|
-
|
|
167
|
-
|
|
349
|
+
### toBeTrue()
|
|
350
|
+
|
|
351
|
+
```ts
|
|
352
|
+
toBeTrue(received): ExpectationResult;
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
Asserts the received value is strictly `true`.
|
|
356
|
+
|
|
357
|
+
### Parameters
|
|
358
|
+
|
|
359
|
+
#### received
|
|
360
|
+
|
|
361
|
+
`unknown`
|
|
362
|
+
|
|
363
|
+
The value to check.
|
|
364
|
+
|
|
365
|
+
### Returns
|
|
366
|
+
|
|
367
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
368
|
+
|
|
369
|
+
### toContainAllValues()
|
|
370
|
+
|
|
371
|
+
```ts
|
|
372
|
+
toContainAllValues(received, expectedValues): object;
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
Asserts that all expected values are present in the received array or object values.
|
|
376
|
+
|
|
377
|
+
### Parameters
|
|
378
|
+
|
|
379
|
+
#### received
|
|
380
|
+
|
|
381
|
+
`unknown`
|
|
382
|
+
|
|
383
|
+
The array or object to check.
|
|
384
|
+
|
|
385
|
+
#### expectedValues
|
|
386
|
+
|
|
387
|
+
`unknown`[]
|
|
388
|
+
|
|
389
|
+
The values that must all be present.
|
|
390
|
+
|
|
391
|
+
### Returns
|
|
392
|
+
|
|
393
|
+
`object`
|
|
394
|
+
|
|
395
|
+
#### pass
|
|
396
|
+
|
|
397
|
+
```ts
|
|
398
|
+
pass: boolean = false;
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
#### message
|
|
402
|
+
|
|
403
|
+
```ts
|
|
404
|
+
message: () => string;
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
##### Returns
|
|
408
|
+
|
|
409
|
+
`string`
|
|
410
|
+
|
|
411
|
+
### toContainKey()
|
|
412
|
+
|
|
413
|
+
```ts
|
|
414
|
+
toContainKey(received, key): object;
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
Asserts that the received object contains the specified key.
|
|
418
|
+
|
|
419
|
+
### Parameters
|
|
420
|
+
|
|
421
|
+
#### received
|
|
422
|
+
|
|
423
|
+
`object`
|
|
424
|
+
|
|
425
|
+
The object to check.
|
|
426
|
+
|
|
427
|
+
#### key
|
|
428
|
+
|
|
429
|
+
`string`
|
|
430
|
+
|
|
431
|
+
The key that should be present.
|
|
432
|
+
|
|
433
|
+
### Returns
|
|
434
|
+
|
|
435
|
+
`object`
|
|
436
|
+
|
|
437
|
+
#### pass
|
|
438
|
+
|
|
439
|
+
```ts
|
|
440
|
+
pass: boolean = true;
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
#### message
|
|
444
|
+
|
|
445
|
+
```ts
|
|
446
|
+
message: () => string;
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
##### Returns
|
|
450
|
+
|
|
451
|
+
`string`
|
|
452
|
+
|
|
453
|
+
### toInclude()
|
|
454
|
+
|
|
455
|
+
```ts
|
|
456
|
+
toInclude(received, value): object;
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
Asserts that the received array, string, or object values include the specified value.
|
|
460
|
+
|
|
461
|
+
### Parameters
|
|
462
|
+
|
|
463
|
+
#### received
|
|
464
|
+
|
|
465
|
+
`unknown`
|
|
466
|
+
|
|
467
|
+
The array, string, or object to search within.
|
|
468
|
+
|
|
469
|
+
#### value
|
|
470
|
+
|
|
471
|
+
`any`
|
|
472
|
+
|
|
473
|
+
The value to look for.
|
|
474
|
+
|
|
475
|
+
### Returns
|
|
476
|
+
|
|
477
|
+
`object`
|
|
478
|
+
|
|
479
|
+
#### pass
|
|
480
|
+
|
|
481
|
+
```ts
|
|
482
|
+
pass: boolean;
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
#### message
|
|
486
|
+
|
|
487
|
+
```ts
|
|
488
|
+
message: () => string;
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
##### Returns
|
|
492
|
+
|
|
493
|
+
`string`
|
|
494
|
+
|
|
495
|
+
### toIncludeAllMembers()
|
|
496
|
+
|
|
497
|
+
```ts
|
|
498
|
+
toIncludeAllMembers(received, expected): ExpectationResult;
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
Asserts that the received array includes all members of the expected array.
|
|
502
|
+
|
|
503
|
+
### Parameters
|
|
504
|
+
|
|
505
|
+
#### received
|
|
506
|
+
|
|
507
|
+
`unknown`[]
|
|
508
|
+
|
|
509
|
+
The array to check.
|
|
510
|
+
|
|
511
|
+
#### expected
|
|
512
|
+
|
|
513
|
+
`unknown`[]
|
|
514
|
+
|
|
515
|
+
The members that must all be present.
|
|
516
|
+
|
|
517
|
+
### Returns
|
|
518
|
+
|
|
519
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
520
|
+
|
|
521
|
+
### toContainAllKeys()
|
|
522
|
+
|
|
523
|
+
```ts
|
|
524
|
+
toContainAllKeys(received, expectedKeys): ExpectationResult;
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
Asserts that the received object contains all of the specified keys.
|
|
528
|
+
|
|
529
|
+
### Parameters
|
|
530
|
+
|
|
531
|
+
#### received
|
|
532
|
+
|
|
533
|
+
`object`
|
|
534
|
+
|
|
535
|
+
The object to check.
|
|
536
|
+
|
|
537
|
+
#### expectedKeys
|
|
538
|
+
|
|
539
|
+
`string`[]
|
|
540
|
+
|
|
541
|
+
The keys that must all be present.
|
|
542
|
+
|
|
543
|
+
### Returns
|
|
544
|
+
|
|
545
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
546
|
+
|
|
547
|
+
### toContainValues()
|
|
548
|
+
|
|
549
|
+
```ts
|
|
550
|
+
toContainValues(received, expectedValues): ExpectationResult;
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
Asserts that the received object contains all of the specified values (using deep equality).
|
|
554
|
+
|
|
555
|
+
### Parameters
|
|
556
|
+
|
|
557
|
+
#### received
|
|
558
|
+
|
|
559
|
+
`object`
|
|
560
|
+
|
|
561
|
+
The object to check.
|
|
562
|
+
|
|
563
|
+
#### expectedValues
|
|
564
|
+
|
|
565
|
+
`unknown`[]
|
|
566
|
+
|
|
567
|
+
The values that must all be present.
|
|
568
|
+
|
|
569
|
+
### Returns
|
|
570
|
+
|
|
571
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
572
|
+
|
|
573
|
+
### toBeEmpty()
|
|
574
|
+
|
|
575
|
+
```ts
|
|
576
|
+
toBeEmpty(received): ExpectationResult;
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
Asserts the received value is empty (zero-length array/string, empty object, or empty Map/Set).
|
|
580
|
+
|
|
581
|
+
### Parameters
|
|
582
|
+
|
|
583
|
+
#### received
|
|
584
|
+
|
|
585
|
+
`unknown`
|
|
586
|
+
|
|
587
|
+
The value to check.
|
|
588
|
+
|
|
589
|
+
### Returns
|
|
590
|
+
|
|
591
|
+
[`ExpectationResult`](#../interfaces/ExpectationResult)
|
|
592
|
+
|
|
593
|
+
### toBeValidDate()
|
|
594
|
+
|
|
595
|
+
```ts
|
|
596
|
+
toBeValidDate(received): object;
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
Asserts the received value is a valid Date instance (not an invalid date).
|
|
600
|
+
|
|
601
|
+
### Parameters
|
|
602
|
+
|
|
603
|
+
#### received
|
|
604
|
+
|
|
605
|
+
`unknown`
|
|
606
|
+
|
|
607
|
+
The value to check.
|
|
608
|
+
|
|
609
|
+
### Returns
|
|
610
|
+
|
|
611
|
+
`object`
|
|
612
|
+
|
|
613
|
+
#### pass
|
|
614
|
+
|
|
615
|
+
```ts
|
|
616
|
+
pass: boolean = isValid;
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
#### message
|
|
620
|
+
|
|
621
|
+
```ts
|
|
622
|
+
message: () => string;
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
##### Returns
|
|
626
|
+
|
|
627
|
+
`string`
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
[npm-badge]: https://img.shields.io/npm/v/@xylabs/vitest-matchers.svg
|
|
631
|
+
[npm-link]: https://www.npmjs.com/package/@xylabs/vitest-matchers
|
|
632
|
+
[license-badge]: https://img.shields.io/npm/l/@xylabs/vitest-matchers.svg
|
|
633
|
+
[license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/vitest-matchers",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.96",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"log",
|
|
@@ -31,12 +31,10 @@
|
|
|
31
31
|
"exports": {
|
|
32
32
|
".": {
|
|
33
33
|
"types": "./dist/neutral/index.d.ts",
|
|
34
|
-
"import": "./dist/neutral/index.mjs",
|
|
35
34
|
"default": "./dist/neutral/index.mjs"
|
|
36
35
|
},
|
|
37
36
|
"./package.json": "./package.json"
|
|
38
37
|
},
|
|
39
|
-
"types": "./dist/neutral/index.d.ts",
|
|
40
38
|
"files": [
|
|
41
39
|
"dist",
|
|
42
40
|
"!**/*.bench.*",
|
|
@@ -45,16 +43,11 @@
|
|
|
45
43
|
"README.md"
|
|
46
44
|
],
|
|
47
45
|
"devDependencies": {
|
|
48
|
-
"@
|
|
49
|
-
"@xylabs/
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"esbuild": "^0.28.0",
|
|
54
|
-
"typescript": "^5"
|
|
55
|
-
},
|
|
56
|
-
"peerDependencies": {
|
|
57
|
-
"vitest": ">=3 <5"
|
|
46
|
+
"@xylabs/toolchain": "~7.10.4",
|
|
47
|
+
"@xylabs/tsconfig": "~7.10.4",
|
|
48
|
+
"typescript": "^5",
|
|
49
|
+
"vite": "^8.0.8",
|
|
50
|
+
"vitest": "~4.1.4"
|
|
58
51
|
},
|
|
59
52
|
"engines": {
|
|
60
53
|
"node": ">=18"
|