Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 75c7c40

Browse files
authored
docs: use admonitions in ExpectAPI.md (#12679)
1 parent 8436c06 commit 75c7c40

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

docs/ExpectAPI.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ test('numeric ranges', () => {
6767
});
6868
```
6969

70-
_Note_: In TypeScript, when using `@types/jest` for example, you can declare the new `toBeWithinRange` matcher in the imported module like this:
70+
:::note
71+
72+
In TypeScript, when using `@types/jest` for example, you can declare the new `toBeWithinRange` matcher in the imported module like this:
7173

7274
```ts
7375
interface CustomMatchers<R = unknown> {
@@ -83,6 +85,8 @@ declare global {
8385
}
8486
```
8587

88+
:::
89+
8690
#### Async Matchers
8791

8892
`expect.extend` also supports async matchers. Async matchers return a Promise so you will need to await the returned value. Let's use an example matcher to illustrate the usage of them. We are going to implement a matcher called `toBeDivisibleByExternalValue`, where the divisible number is going to be pulled from an external source.
@@ -800,7 +804,11 @@ test('drinkEach drinks each drink', () => {
800804
});
801805
```
802806

803-
Note: the nth argument must be positive integer starting from 1.
807+
:::note
808+
809+
The nth argument must be positive integer starting from 1.
810+
811+
:::
804812

805813
### `.toHaveReturned()`
806814

@@ -899,7 +907,11 @@ test('drink returns expected nth calls', () => {
899907
});
900908
```
901909

902-
Note: the nth argument must be positive integer starting from 1.
910+
:::note
911+
912+
The nth argument must be positive integer starting from 1.
913+
914+
:::
903915

904916
### `.toHaveLength(number)`
905917

@@ -1205,7 +1217,11 @@ describe('the La Croix cans on my desk', () => {
12051217
});
12061218
```
12071219

1208-
> Note: `.toEqual` won't perform a _deep equality_ check for two errors. Only the `message` property of an Error is considered for equality. It is recommended to use the `.toThrow` matcher for testing against errors.
1220+
:::tip
1221+
1222+
`.toEqual` won't perform a _deep equality_ check for two errors. Only the `message` property of an Error is considered for equality. It is recommended to use the `.toThrow` matcher for testing against errors.
1223+
1224+
:::
12091225

12101226
If differences between properties do not help you to understand why a test fails, especially if the report is large, then you might move the comparison into the `expect` function. For example, use `equals` method of `Buffer` class to assert whether or not buffers contain the same content:
12111227

@@ -1340,7 +1356,11 @@ test('throws on octopus', () => {
13401356
});
13411357
```
13421358

1343-
> Note: You must wrap the code in a function, otherwise the error will not be caught and the assertion will fail.
1359+
:::tip
1360+
1361+
You must wrap the code in a function, otherwise the error will not be caught and the assertion will fail.
1362+
1363+
:::
13441364

13451365
You can provide an optional argument to test that a specific error is thrown:
13461366

0 commit comments

Comments
 (0)