Skip to content

Mounted components do not automatically unmount once the it statement finishes #1367

@gbyesiltas

Description

@gbyesiltas

Environment

I got this on my project, but was able to reproduce it on the stackblitz starter. Here's the info from there:

Working directory: /home/projects/github-rg6uhsqu                                                                                                                                         nuxi 15:08:38
Nuxt project info:                                                                                                                                                                        nuxi 15:08:38

------------------------------
- Operating System: Linux
- Node Version:     v20.19.1
- Nuxt Version:     4.0.1
- CLI Version:      3.26.4
- Nitro Version:    2.12.4
- Package Manager:  npm@10.8.2
- Builder:          -
- User Config:      devtools, compatibilityDate
- Runtime Modules:  -
- Build Modules:    -
------------------------------

Reproduction

Reproduction: https://stackblitz.com/edit/github-rg6uhsqu?file=components%2Ftests%2FMyComponent.spec.ts

  1. Run npm run test
  2. See that the console.log from the watcher triggers both from Component 1 and Component 2; even though the state is only changed in the second test
  3. Unmounting the first wrapper within it's it block fixes the issue

Describe the bug

It seems that wrappers do not unmount automatically after their it statements. I'm not sure if this is expected behaviour, but I wouldn't expect it and I'm worried that it can cause some data-contamination between tests and cause memory leaks?

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions