Alias seems to not store it's value
See original GitHub issueCurrent behavior
During the test I’m comparing two values
First one is stored as ‘backgroundImageDefault’ with following code
cy.get(selectors.pageAddress)
.prev()
.invoke('css', 'backgroundImage')
.as('backgroundImageDefault');
At this point the backgroundImageDefault
has value https://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
.
cy.get('@backgroundImageDefault').then((background) => {
cy.get(selectors.pageAddress)
.prev()
.should('not.have.css', 'background-image', background);
});
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 of https://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
Issue Analytics
- State:
- Created 9 months ago
- Reactions:5
- Comments:13 (6 by maintainers)
Top Results From Across the Web
JavaScript function aliasing doesn't seem to work
This function is declared in the Window scope and when you invoke it the value of this inside the sum function will be...
Read more >Variables and Aliases
Whenever you have mutable objects and you're trying to compare them, you'll need to store their values. Using const is a perfect way...
Read more >Using Alias Sets Part 1
Alias sets provide a means resolving attribute values that specify ACL, ... Alias sets are stored as dm_alias_set objects in Documentum.
Read more >Lambda function aliases
An alias can point only to a function version, not to another alias. You can update an alias to point to a new...
Read more >Alias Variables Extensions
An object can be mapped onto, and stored and manipulated in an array, ... SET with an alias container as left-hand side target...
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
I like
A
andB
😃B
is more explicit butA
gives no work if someone is not using aliases to store valuesI like
A
, would we probably default to{ type: 'query' }
and document that this is how it was always meant to work? I mean it’s a little more work for people depending on thevalue
but speaking for my team, we can manage to be explicit in our tests that need a different default.I think
C
would be confusing to change it on theget
at least in my mind we focus more on when we store values, like if we wanted to do a.as("originalValue")
and then later compare to a new value, sample usage: