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.mount should remove the last mounted component if called multiple times in same test #24329

Closed
ZachJW34 opened this issue Oct 20, 2022 · 3 comments
Assignees
Labels
CT Issue related to component testing

Comments

@ZachJW34
Copy link
Contributor

ZachJW34 commented Oct 20, 2022

Current behavior

Scenario:

it('calls mount twice', () => {
  cy.mount(MyApp)
  cy.mount(MyApp)
})

Framework dependent behavior:

  • Angular: Throws error upon second mount
  • Vue: Mounts multiple components
  • Svelte: Mounts multiple components
  • React: Removes and remounts
  • Vue2: Mounts multiple components

Desired behavior

The last component mounted should be removed from the DOM/cleaned up.

Test code to reproduce

import HelloWorld from "./components/HelloWorld.vue";

it("default", () => {
  cy.mount(HelloWorld, { props: { msg: "Component 1" } });
  cy.mount(HelloWorld, { props: { msg: "Component 2" } });
  cy.mount(HelloWorld, { props: { msg: "Component 3" } });
});

Screen Shot 2022-10-20 at 5 11 51 PM

Cypress Version

10.10.0

Node version

v16.17.1

Operating System

macOS 12.4

Debug Logs

No response

Other

No response

@ZachJW34 ZachJW34 added the CT Issue related to component testing label Oct 20, 2022
@baus
Copy link
Collaborator

baus commented Oct 24, 2022

@ZachJW34 ZachJW34 self-assigned this Oct 27, 2022
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: review and removed stage: in progress stage: needs review The PR code is done & tested, needs review labels Oct 31, 2022
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 3, 2022

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

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 10, 2022

Released in 11.0.0.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CT Issue related to component testing
Projects
None yet
Development

No branches or pull requests

3 participants