-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Alias seems to not store it's value #25173
Comments
Facing same issue after updating to v12.1.0 |
I am also facing this issue in v12.1.0 |
Not sure if it's the same issue, but starting v12.0 following code doesn't work. |
This was an intentional change in the behavior of aliases - basically we hadn't realized people were relying on the old behavior, and thought that accurately reflecting the current state of the application was always desired. Currently discussing with the rest of the team and trying to figure out a good solution here, but as a temporary workaround, you can add a non-query command to 'break' the subject chain. Eg:
.then() breaks the subject chain - you'll just be aliasing the value, not the full query of Just to reiterate, this is just a workaround you can use - we're still figuring out what to do here. :) |
@BlueWinds Am I right that if we need stored value it's better to use aliases this way?(with cy.get(selectors.pageAddress)
.prev()
.invoke('css', 'backgroundImage')
.as('backgroundImageDefault');
cy.then(function() {
cy.get(selectors.pageAddress)
.prev()
.should('not.have.css', 'background-image', this.backgroundImageDefault);
}); |
A couple of options we're considering: A. B. C. D. Anyone have strong feelings about any of these? I'm leaning towards A. |
I like I think
|
I like
|
|
I also believe that both |
I'm as well for options @BlueWinds, could you please tell if those changes would bring back functionality like this to work again? |
That sounds like a different and unrelated issue; please open a new ticket with a reproduction so we can look at that separately. |
I wouldn't say using |
If anyone is interested, I created a repo with some tests to show what still works and what is broken: https://github.com/verheyenkoen/cypress-primitive-alias-bug/blob/main/cypress/e2e/test.cy.js |
Can't believe that the use case (save value for later, while changed in between) has been ignored during development of 12+. It is a central piece in my cypress code. |
Just keep everything as it was before the bug, values should be the default please. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior
During the test I'm comparing two values
First one is stored as 'backgroundImageDefault' with following code
At this point the
backgroundImageDefault
has valuehttps://host.com/smth/defaultImage.jpg
.Then I'm changing the image, the new image obviously has a new address,
https://host.com/smth/changedImage.jpg
.It fails becouse when comparing it seems that alias 'backgroundImageDefault' now has value of
https://host.com/smth/changedImage.jpg
instead of it's assigned value ofhttps://host.com/smth/defaultImage.jpg
.Desired behavior
Until I upgraded to 12.0.0/12.1.0 the test simply passed and the value stored in the
backgroundImageDefault
was correct.Test code to reproduce
It's the code mentioned in current behaviour
Cypress Version
12.1.0
Node version
v16.15.1
Operating System
macOS 13.1
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered: