Skip to content

Commit 6021418

Browse files
authored
add example assertion with text and regular expression (#3768)
1 parent cd21ce4 commit 6021418

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

content/guides/references/assertions.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@ cy.get('textarea').should('have.value', 'foo bar baz')
229229
```javascript
230230
// retry until this span does not contain 'click me'
231231
cy.get('a').parent('span.help').should('not.contain', 'click me')
232+
// the element's text should start with "Hello"
233+
cy.get('#greeting')
234+
.invoke('text')
235+
.should('match', /^Hello/)
236+
// tip: use cy.contains to find element with its text
237+
// matching the given regular expression
238+
cy.contains('#a-greeting', /^Hello/)
232239
```
233240

234241
### Visibility

0 commit comments

Comments
 (0)