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

Cypress.Commands.overwrite doesn't pass down the context #5101

Closed
x-yuri opened this issue Sep 7, 2019 · 4 comments · Fixed by #9589
Closed

Cypress.Commands.overwrite doesn't pass down the context #5101

x-yuri opened this issue Sep 7, 2019 · 4 comments · Fixed by #9589
Labels
pkg/driver type: unexpected behavior User expected result, but got another

Comments

@x-yuri
Copy link

x-yuri commented Sep 7, 2019

Current behavior:

Cypress.Commands.overwrite('then', function(originalCommand, subject, fn, options = {}) {
    return originalCommand.call(this, subject, options, fn);
});
 
specify('aliases work', function () {
    cy.wrap(1).as('myAlias');
    cy.wrap(2).then(function(subj) {
        expect(this.myAlias).to.eq(1); // undefined
    });
});

Desired behavior:

The test succeeds.

Steps to reproduce: (app code and test code)

https://github.com/x-yuri/issues/tree/cypress-overwrite

More info

Cypress.Commands.overwrite() is used by cypress-commands package. Is there a possibly better way to change then() command?

Versions

Cypress 3.4.0, Arch Linux, Electron 61

@Lakitna
Copy link
Contributor

Lakitna commented Oct 17, 2019

Pinging @jennifer-shehane as this has not been answered within a month :)

@bahmutov
Copy link
Contributor

bahmutov commented Dec 9, 2020

Good:

Screen Shot 2020-12-09 at 10 13 03 AM

Broken:

Screen Shot 2020-12-09 at 10 15 18 AM

@cypress-bot cypress-bot bot added 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 Dec 9, 2020
@cypress-bot cypress-bot bot added the stage: pending release There is a closed PR for this issue label Dec 11, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 11, 2020

The code for this is done in cypress-io/cypress#9589, 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 Dec 11, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 21, 2020

Released in 6.2.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v6.2.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 Dec 21, 2020
@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Dec 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/driver type: unexpected behavior User expected result, but got another
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants