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

Bug: setData() incorrectly sets object prototype methods as keys #2257

Closed
MetRonnie opened this issue Nov 24, 2023 · 4 comments · Fixed by #2265
Closed

Bug: setData() incorrectly sets object prototype methods as keys #2257

MetRonnie opened this issue Nov 24, 2023 · 4 comments · Fixed by #2265
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@MetRonnie
Copy link

Describe the bug

Using setData() with an object is causing Object prototype methods to be set as keys on the object.

To Reproduce

Stackblitz isn't loading for me. But here is hopefully a clear example:

const wrapper = mountFunction()
expect(wrapper.vm.filters).toEqual({
  'workflow state': [],
  'task state': [],
}) // ✔
expect(Object.keys(wrapper.vm.filters)).toEqual([
  'workflow state',
  'task state',
]) // ✔

await wrapper.setData({
  filters: {
    'workflow state': [],
    'task state': [],
  }
})
expect(Object.keys(wrapper.vm.filters)).toEqual([
  'workflow state',
  'task state',
]) // ✖
- Expected
+ Received

  Array [
    "workflow state",
    "task state",
+   "constructor",
+   "__defineGetter__",
+   "__defineSetter__",
+   "hasOwnProperty",
+   "__lookupGetter__",
+   "__lookupSetter__",
+   "isPrototypeOf",
+   "propertyIsEnumerable",
+   "toString",
+   "valueOf",
+   "toLocaleString",

Expected behavior

Object prototype methods should not be set as keys on objects.

Related information:

    "vue": "3.3.4",
    "@vue/test-utils": "2.4.2",
    "vitest": "0.34.6"

Additional context

I think this was introduced by #2166

@MetRonnie MetRonnie added the bug Something isn't working label Nov 24, 2023
@cexbrayat
Copy link
Member

Hi @MetRonnie

Interesting. You're probably right that this is a regression from #2166

Would you like to open a PR to fix this? We would gladly review and merge it.

@MetRonnie
Copy link
Author

I'm afraid I don't have a lot of time on my hands

@cexbrayat
Copy link
Member

No worries, maybe someone will pick it up.

@cexbrayat cexbrayat added the good first issue Good for newcomers label Nov 27, 2023
@Haberkamp
Copy link
Contributor

I'll create a PR for that issue during next days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants