Skip to content

Commit 32de2ca

Browse files
committed
Documents clearly today .not behavior
1 parent 242e849 commit 32de2ca

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

docs/API.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,29 @@ await expect(elem).toHaveElementClass(/Container/i)
880880

881881
In addition to the `expect-webdriverio` matchers you can use builtin Jest's [expect](https://jestjs.io/docs/expect) assertions or [expect/expectAsync](https://jasmine.github.io/api/edge/global.html#expect) for Jasmine.
882882

883+
## Modifiers
884+
885+
WebdriverIO supports usage of modifiers as `.not` and it will wait until the reverse condition is meet
886+
887+
```ts
888+
// Wait until the element is no longer present
889+
await expect(element).not.toBeDisplayed()
890+
891+
// Wait until the text is no more 'some title'
892+
await expect(browser).not.toHaveTitle('some title')
893+
```
894+
895+
In case immediate assertion is required, use `{ wait: 0 }`
896+
```ts
897+
// Ensure element is not present right now
898+
await expect(element).not.toBeDisplayed({ wait: 0 })
899+
900+
// Ensure the text is not 'some title' right now
901+
await expect(browser).not.toHaveTitle('some title', { wait: 0 })
902+
```
903+
904+
Note: You can pair `.not` with asymmetric matchers, but to enable the wait-until behavior, `.not` must be used directly on the `expect()` call.
905+
883906
## Asymmetric Matchers
884907

885908
WebdriverIO supports usage of asymmetric matchers wherever you compare text values, e.g.:

0 commit comments

Comments
 (0)