Skip to content

Commit

Permalink
add cy.stable example (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov authored Jan 18, 2024
1 parent 6856e3c commit 9fedde3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
26 changes: 26 additions & 0 deletions docs/recipes/element-is-stable.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,29 @@ If we click on the command, we see the details in the DevTools console
![stableText command](./pics/stable-command.png)

<!-- fiddle-end -->

## Using cy.stable command

My plugin [cypress-map](https://github.com/bahmutov/cypress-map) includes the `cy.stable` child query command.

<!-- fiddle cy.stable / text does not change -->

```html
<div id="message">--</div>
<script>
setTimeout(() => {
document.getElementById('message').innerText = 'loading...'
}, 1000)
setTimeout(() => {
document.getElementById('message').innerText = 'Hello'
}, 2000)
</script>
```

```js
cy.get('#message')
.stable('text', 1500)
.should('have.text', 'Hello')
```

<!-- fiddle-end -->
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"common-tags": "1.8.0",
"cypress": "13.6.2",
"cypress-book": "1.5.0",
"cypress-map": "^1.24.0",
"cypress-map": "^1.25.0",
"cypress-markdown-preprocessor": "1.10.3",
"cypress-recurse": "^1.31.2",
"dependency-version-badge": "1.2.0",
Expand Down

0 comments on commit 9fedde3

Please sign in to comment.