Commit 886262d
committed
feat(@probitas/expect): allow PropertySatisfying matcher to handle null/undefined values
Previously, toHavePropertySatisfying performed automatic property
existence checks and rejected null/undefined values before calling
the matcher. This prevented users from validating null values,
checking for non-existent properties, or handling broken object paths.
Since PropertySatisfying is designed for custom user-defined validation
logic, users should have full control over all validation aspects,
including property existence checks. This change removes the automatic
guards and always invokes the matcher with the actual value (or
undefined if the property path is invalid).
Changes:
- Remove toHaveProperty existence check before matcher execution
- Remove ensureNonNullish call that rejected null/undefined
- Simplify error handling to only report matcher failures
- Add test cases for null values and broken intermediate paths1 parent 5d997db commit 886262d
File tree
3 files changed
+52
-27
lines changed- packages/probitas-expect/mixin
- __snapshots__
3 files changed
+52
-27
lines changedLines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
113 | | - | |
| 112 | + | |
| 113 | + | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
136 | | - | |
| 135 | + | |
| 136 | + | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
318 | 317 | | |
319 | 318 | | |
320 | 319 | | |
321 | | - | |
322 | 320 | | |
323 | 321 | | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
| 322 | + | |
333 | 323 | | |
334 | 324 | | |
335 | 325 | | |
| |||
344 | 334 | | |
345 | 335 | | |
346 | 336 | | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | 337 | | |
358 | 338 | | |
359 | 339 | | |
| |||
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
495 | 540 | | |
496 | 541 | | |
497 | 542 | | |
| |||
0 commit comments