You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api-documents/matchers.md
+11-2Lines changed: 11 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,15 @@ test('two plus two is four', () => {
10
10
11
11
In this code, `expect(2+2)` returns an "Value" object. You typically won't do much with these objects except call matchers on them. In this code, `.equal(4)` is the matcher. When Jest runs, it tracks all the failing matchers so that it can print out nice error messages for you.
12
12
13
+
### Not
14
+
15
+
`not` matcher can reverse the matching results of all subsequent `matcher` statements.
16
+
17
+
```ts
18
+
expect(1).not.equal(2); // success
19
+
expect(1).not.equal(1); // fail
20
+
```
21
+
13
22
### Equal
14
23
15
24
In the most condition, `equal` is similar as `==`, you can use this matcher to compare `i32 | i64 | u32 | u64 | f32 | f64 | string` just like `==`. What's more, it can also be used to compare some inner type, such as `Array | Map | Set`.
@@ -24,12 +33,12 @@ Most ways of comparing numbers have matcher equivalents, like `equal`, `greaterT
24
33
25
34
Specially, for float type, use `closeTo` instead of `equal` to avoid rounding error.
26
35
27
-
## Nullable
36
+
###Nullable
28
37
29
38
`isNull` and `notNull` matchers can be used to a nullable object.
30
39
Of course, you can also use `equal` and `notEqual` to do same thing with explicit generic declaration `expect<T | null>()`
31
40
32
-
## Typing
41
+
###Typing
33
42
34
43
`isa` and `isExactly` matchers can be used to compare typing.
0 commit comments