Skip to content
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

cy.its() no longer waits on undefined #3837

Closed
tnightingale opened this issue Mar 27, 2019 · 3 comments
Closed

cy.its() no longer waits on undefined #3837

tnightingale opened this issue Mar 27, 2019 · 3 comments

Comments

@tnightingale
Copy link

@tnightingale tnightingale commented Mar 27, 2019

Current behavior:

cy.its() yields undefined.

cy.window().its('__store__').then((store) => {
    ...
    /* `store` is undefined as value is yielded before my application gets a chance to set `window.__store__ = myStore;` */
});

Desired behavior:

Docs state:

.its() will automatically retry itself until the property exists on the subject.

https://docs.cypress.io/api/commands/its.html#Assertions

Steps to reproduce: (app code and test code)

Interestingly, asserting that the yielded property exists resolves this issue:

cy.window().its('__store__').should('exist').then((store) => {
    ...
    /* `store` is *not* `undefined` 👌 */
});

I suspect all that is required is that the documentation needs to be updated to indicate that by default it will yield undefined unless there's a subsequent command that triggers the retry behaviour/state.

Versions

Cypress 3.2.0
macOS: 10.14.3
Chrome 73

@Bkucera
Copy link
Member

@Bkucera Bkucera commented Mar 27, 2019

Hi @tnightingale thanks for letting us know about this. The PR #3226 was incorrectly targeted at the wrong branch.

We'll revert this in the next release, and will keep the behavior you expect.

The goal of the PR was to allow this to work:

cy.window().its('someProp').should('not.exist')

But we'll keep the default behavior of retrying when undefined

@cypress-bot
Copy link

@cypress-bot cypress-bot bot commented Apr 15, 2019

The code for this is done in cypress-io/cypress#3870, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link

@cypress-bot cypress-bot bot commented May 17, 2019

Released in 3.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants