You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* upgrade Cypress to v12
* bump cypress github action versions
* update a few more specs for v12
* fix a few more tests
* fix more tests
* remove trailing slash for JS
* fix more errors
* fix more errors
* fix more examples
* two more fixes
Copy file name to clipboardExpand all lines: docs/commands/misc.md
+21-11
Original file line number
Diff line number
Diff line change
@@ -42,10 +42,17 @@ Let's say we want to print to the Command Log the number of elements the previou
42
42
cy.get('#log-fruits li')
43
43
// you can add assertions to make sure the list is populated
44
44
.its('length')
45
-
// prints just the number
46
-
.then(cy.log)
45
+
// prints just the number,
46
+
// must be careful to yield the value to the next command
47
+
.then((x) => {
48
+
cy.log(x)
49
+
cy.wrap(x, { log:false })
50
+
})
47
51
// if you want to add a message, use a callback function
48
-
.then((n) =>cy.log(`found ${n} items`))
52
+
.then((n) => {
53
+
cy.log(`found ${n} items`)
54
+
cy.wrap(n, { log:false })
55
+
})
49
56
// because cy.log never changes the current subject
50
57
// we can confirm the found number of elements by adding an assertion
51
58
.should('equal', 5)
@@ -59,18 +66,21 @@ cy.get('#log-fruits li')
59
66
.filter(':contains("Grape")')
60
67
.its('length')
61
68
// if you want to add a message, use a callback function
62
-
.then((n) =>cy.log(`found ${n} fruits with "Grape" in them`))
69
+
.then((n) => {
70
+
cy.log(`found ${n} fruits with "Grape" in them`)
71
+
cy.wrap(n, { log:false })
72
+
})
63
73
// confirm the number of elements
64
74
.should('equal', 2)
65
75
```
66
76
67
77
<!-- fiddle-end -->
68
78
69
-
### cy.log yields the original argument
79
+
### cy.log does not yield the original argument
70
80
71
-
Because `cy.log` yields `undefined`, Cypress will yield the original argument to the next command or assertion. For example, let's print the element's node name and then confirm its value.
81
+
Because `cy.log` yields `null`, Cypress will NOT yield the original argument to the next command or assertion. Thus you need to wrap the original value.
72
82
73
-
<!-- fiddle .log() / yields the original argument -->
83
+
<!-- fiddle .log() / does not yield the original argument -->
0 commit comments