@@ -37,15 +37,15 @@ important to understand the different rules by which they operate.
3737 log.
3838- ** Non-queries** only execute once.
3939
40- For example, there are 7 queries (2 of them assertions) and 2 non-queries in the
41- test below.
40+ For example, there are 4 queries, an action, and 2 assertions in
41+ the test below.
4242
4343``` javascript
4444it (' creates an item' , () => {
4545 // Non-query commands only execute once.
4646 cy .visit (' /' )
4747
48- // The queries .focused() and .should() link together,
48+ // The .focused() query and .should() assertion link together,
4949 // rerunning until the currently focused element has
5050 // the 'new-todo' class
5151 cy .focused ().should (' have.class' , ' new-todo' )
@@ -55,7 +55,7 @@ it('creates an item', () => {
5555 // the non-query `.type()`.
5656 cy .get (' .header' ).find (' .new-todo' ).type (' todo A{enter}' )
5757
58- // Three queries chained together
58+ // Two queries and an assertion chained together
5959 cy .get (' .todoapp' ).find (' .todo-list li' ).should (' have.length' , 1 )
6060})
6161```
@@ -136,12 +136,16 @@ Within a few milliseconds after the DOM updates, the linked queries
136136
137137## Multiple assertions
138138
139- Chains of commands are always executed in order, with all previous queries
140- forming the subject of each following command.
139+ Queries and assertions are always executed in order, and always retry 'from the
140+ top'. If you have multiple assertions, Cypress will retry until each passes
141+ before moving on to the next one.
141142
142- For example, the following test has the [ .get()] ( /api/commands/get ) ,
143- [ ` .should() ` ] ( /api/commands/should ) and [ ` .and() ` ] ( /api/commands/and ) commands
144- chained together. All three of these are queries.
143+ For example, the following test has [ ` .should() ` ] ( /api/commands/should ) and
144+ [ ` .and() ` ] ( /api/commands/and ) assertions. ` .and() ` is an alias of the
145+ ` .should() ` command, so the second assertion is really a custom callback
146+ assertion in the form of the [ ` .should(cb) ` ] ( /api/commands/should#Function )
147+ function with 2 [ ` expect ` ] ( /guides/references/assertions#BDD-Assertions )
148+ assertions inside of it.
145149
146150``` javascript
147151it (' creates two items' , () => {
@@ -151,9 +155,9 @@ it('creates two items', () => {
151155 cy .get (' .new-todo' ).type (' todo B{enter}' )
152156
153157 cy .get (' .todo-list li' ) // query
154- .should (' have.length' , 2 ) // query
158+ .should (' have.length' , 2 ) // assertion
155159 .and (($li ) => {
156- // 2 mocha assertions inside of the .and() query
160+ // 2 mocha assertions inside of the .and() assertion
157161 expect ($li .get (0 ).textContent , ' first item' ).to .equal (' todo a' )
158162 expect ($li .get (1 ).textContent , ' second item' ).to .equal (' todo B' )
159163 })
@@ -163,7 +167,8 @@ it('creates two items', () => {
163167Because the first expect statement
164168(` expect($li.get(0).textContent, 'first item').to.equal('todo a') ` ) fails, the
165169second statement is never reached. The ` .and() ` command fails after timing out,
166- and the Command Log correctly shows that ` .get() ` and ` .should() ` passed, but
170+ and the Command Log correctly shows that the first encountered assertion
171+ ` should('have.length', 2) ` passed, but
167172the "first item" assertion failed.
168173
169174<DocsImage
@@ -179,7 +184,9 @@ will be retried even without any attached assertions until it finds an element
179184with the given index.
180185
181186``` javascript
182- cy .get (' .todo-list li' ).should (' have.length' , 2 ).eq (3 )
187+ cy .get (' .todo-list li' ) // query
188+ .should (' have.length' , 2 ) // assertion
189+ .eq (3 ) // query
183190```
184191
185192<DocsImage
0 commit comments