docs(test-assertions-js): add base matcher mutability caution note
This commit is contained in:
parent
4819747c85
commit
5f0c76f7d4
|
|
@ -308,6 +308,18 @@ test('amount', async () => {
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note that `expect.extend()` is mutable, so overriding base matchers may cause infinite loops, such as below.
|
||||||
|
|
||||||
|
```js title="example.spec.ts"
|
||||||
|
import { expect as baseExpect } from '@playwright/test';
|
||||||
|
|
||||||
|
export const expect = baseExpect.extend({
|
||||||
|
toHaveURL: async (...args: any[]) => {
|
||||||
|
await expect.toHaveURL(...args);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
### Compatibility with expect library
|
### Compatibility with expect library
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue