Cypress: cy.its() no longer waits on undefined

Created on 27 Mar 2019  路  3Comments  路  Source: cypress-io/cypress

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

bug regression

Most helpful comment

Hi @tnightingale thanks for letting us know about this. The PR https://github.com/cypress-io/cypress/pull/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

All 3 comments

Hi @tnightingale thanks for letting us know about this. The PR https://github.com/cypress-io/cypress/pull/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

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.

Released in 3.3.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jennifer-shehane picture jennifer-shehane  路  3Comments

brian-mann picture brian-mann  路  3Comments

zbigniewkalinowski picture zbigniewkalinowski  路  3Comments

SecondFlight picture SecondFlight  路  3Comments

rbung picture rbung  路  3Comments