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;` */
});
Docs state:
.its() will automatically retry itself until the property exists on the subject.
https://docs.cypress.io/api/commands/its.html#Assertions
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.
Cypress 3.2.0
macOS: 10.14.3
Chrome 73
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.
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:
But we'll keep the default behavior of retrying when
undefined