Skip to content

setProps with array concats newItems and oldItems value #876

@tomoki1207

Description

@tomoki1207

Environment

  • Operating System: Linux
  • Node Version: v18.20.3
  • Nuxt Version: 3.12.2
  • CLI Version: 3.12.0
  • Nitro Version: 2.9.6
  • Package Manager: npm@10.2.3
  • Builder: -
  • User Config: devtools, modules
  • Runtime Modules: @nuxt/test-utils/module@3.13.1
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/nuxt-starter-ncxs25?file=components%2FTest.spec.ts

Describe the bug

I called setProps on Component has an Array type prop. However, the resulting prop value is a concatenation of the new array value and the old array value.

const wrapper = await mountSuspended(Test, {
    props: {
      users: [
        { id: 0, name: 'John' },
        { id: 1, name: 'Kate' },
      ],
    },
  });
expect(wrapper.html()).toContain('John'); // props contain John and Kate
await wrapper.setProps({ users: [{ id: 2, name: 'Bob' }] });
expect(wrapper.html()).not.toContain('John');  // !! props contain Bob, John and Kate

This issue occurs when using Wrapper from mountSuspended, but it does not occur when using @vue/test-utils's mount.

What could be the cause of this behavior?

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions