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

Flake with location object #16463

Closed
bahmutov opened this issue May 11, 2021 · 5 comments · Fixed by #16772
Closed

Flake with location object #16463

bahmutov opened this issue May 11, 2021 · 5 comments · Fixed by #16772

Comments

@bahmutov
Copy link
Contributor

Cypress v7.3.0

Reproducible example in https://github.com/bahmutov/cypress-ethereal-email-example/tree/location-flake

The test redirects from localhost to localhost /confirm through Sendgrid URL. Sometimes it works, sometimes it does not (even though the page does load fine)

Screen Shot 2021-05-11 at 3 50 31 PM

When it fails it shows

Screen Shot 2021-05-11 at 3 50 46 PM

Almost like it has temporary blip with the location object and does not retry getting it again

@bahmutov bahmutov added the topic: flake ❄️ Test flake label May 11, 2021
@bahmutov
Copy link
Contributor Author

Found that when failing, it has an empty string

const getLocation = () => {
    const location = cy.getRemoteLocation()
    console.log('location "%s" %s', location.toString(), JSON.stringify(location))

     return _.isString(key)
        // use existential here because we only want to throw
        // on null or undefined values (and not empty strings)
          ? location[key] ?? $errUtils.throwErrByPath('location.invalid_key', { args: { key, location } })
          : location
}

Screen Shot 2021-05-11 at 4 26 03 PM

@bahmutov
Copy link
Contributor Author

Adding guard like this seems to solve the problem and let the test retry

const location = cy.getRemoteLocation()
     console.log('location "%s" %s', location.toString(), JSON.stringify(location))
     if (location === '') {
        return null
     }
}

Screen Shot 2021-05-11 at 4 28 42 PM

@bahmutov
Copy link
Contributor Author

bahmutov commented May 11, 2021

Intersting to see how we go from the local domain to 3rd party domain (probably causing "" location) and then back to the local domain with full location object

Screen Shot 2021-05-11 at 4 29 52 PM

@cypress-bot cypress-bot bot added stage: work in progress There is an open PR for this issue [WIP] stage: needs review The PR code is done & tested, needs review and removed stage: work in progress There is an open PR for this issue [WIP] labels Jun 2, 2021
@cypress-bot cypress-bot bot added the stage: pending release There is a closed PR for this issue label Jun 4, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 4, 2021

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

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label Jun 4, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 7, 2021

Released in 7.5.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v7.5.0, please open a new issue.

@cypress-bot cypress-bot bot removed the stage: pending release There is a closed PR for this issue label Jun 7, 2021
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants