docs(test-assertions-js): add base matcher mutability caution note

This commit is contained in:
Ryan Chung 2024-12-28 06:51:08 -05:00
parent 4819747c85
commit 5f0c76f7d4

View file

@ -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