cy.log now returns null in v10.5, used to be undefined
See original GitHub issueCurrent behavior
cy.log
used to return undefined, so it could be inserted into the command chain without changing the subject
...
.then(cy.log)
...
Now cy.log
returns null
, changing the subject
Desired behavior
cy.log
should still return undefined
Test code to reproduce
Repo and branch https://github.com/bahmutov/cypress-test-tiny/tree/cy-log-bug
describe('cy.log', () => {
it('works', () => {
cy.wrap(42).should('equal', 42)
})
it('does not work', () => {
// not working in Cypress v10.6.0
// not working in v10.5.0
// worked in v10.4.0
// fails with "null" not equal 42
cy.wrap(42).then(cy.log).should('equal', 42)
})
})
Cypress Version
10.5.0
Node version
16
Operating System
mac
Debug Logs
No response
Other
No response
Issue Analytics
- State:
- Created a year ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Why cy.log prints null or undefined - YouTube
Sometimes we call cy. log (variable) yet it always prints null or undefined. In this video, I explain why this happens and how...
Read more >Changelog - Cypress Documentation
Cypress now throws an error if any Cypress commands are invoked from inside a .should() callback. This previously resulted in unusual and undefined...
Read more >Why cy.log Prints Nothing - Gleb Bahmutov
log command prints null or undefined even if the variable is set by the Cypress test. This is a very common question and...
Read more >Fix List for DB2 Version 10.5 for Linux, UNIX and Windows - IBM
APAR Sev. Abstract
IJ11422 2 MEMORY LEAK IN DB2TOP WHEN VIEWING DYNAMIC SQL
IT28111 2 QUERIES USING HASH JOINS MAY HANG INTERMITTENTLY
IT29647 2 SIG#11 RUNNING...
Read more >Best Practices Upgrade to DB2 LUW 10.5 with BLU Acceleration
If wish to downgrade instance back to V10.5 FP1 code base: ... Rolling forward of logs from a previous level is not possible....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ughh, the change makes no sense. Sure, the docs could be saying (an incorrect) thing for 6 years, yet it was not an issue and allowed to quickly print a value inside a long chain. The advice to close the chain with
cy.log
does not really help.The solution is to write a big callback and wrap the value - no, just no. Instead, I would suggest
undefined
from cy.log. I don’t see any reason to change the subject incy.log
, we already have plenty of problems withshould('have.attr')
and similar assertions that do unexpectedly change the subjectcy.log
to intelligently stringify an object when passed in (so it does not collapse it into[object Object]
)just my two million cents
@bahmutov The conclusion we’ve come to internally is that this was not an intentional change, and it is just a coincidence that the behavior actually now matches our documentation. So, this isn’t strictly a bug but rather a feature request to change the documented behavior back to the previous implementation. That said, it’s a good one - the use case you’ve lined out feels very useful. We’ll send this on to the team to do analysis and prioritize
(internal convo ref)