New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
within
does not yield the subject from previous command
#2106
Comments
The Reproducible example it('get an el', () => {
cy.visit('http://example.cypress.io')
cy.get('.banner').within(($banner) => {
console.log($banner) // logs .banner el
cy.get('a').first()
}).then(($banner) => {
console.log($banner) // logs anchor el and not banner
})
}) Now the question is, are the docs inaccurate? Or is the implementation inaccurate? So, we need to make a decision on what would likely be expected to be yielded from a |
Any update on this? Since |
The code for this is done in cypress-io/cypress#8699, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior:
I am having trouble with
.within()
and.should()
..within()
seems to yield the last subject that was yielded inside its scope rather than the subject from the previous command.The
.within()
command yields theli.first
subject instead of.query-list
.And I'm not sure if this is a separate issue, but I found it at the same time: when I run the
.get()
command on#query-btn
after the.should()
command, it tries to findli.first #query-btn
In this example, I expected
.should()
to assert that.query-list
was visible, but it instead receivesnull
.Desired behavior:
The docs state:
But in my examples it seems to yield the last subject that was yielded from within its own scope.
Steps to reproduce:
Reproduction repo: https://github.com/hooskers/cypress-test-tiny
Test cases are in
cypress/integration/spec.js
Versions
Cypress: 3.0.2
Browser: Chrome 67.0.3396.99
OS: MacOS 10.13.5
The text was updated successfully, but these errors were encountered: