Skip to content

Vuex would throw warnings about modules getting overridden if I call render() in more than one test #158

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

Closed
davidchai717 opened this issue Sep 25, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@davidchai717
Copy link

Oddly this doesn't have if you only have one test that calls render(component, { state: { foo: true }, modules: {...} }). But once I start adding in a second test where I need to render the same component with a Vuex store, it immediately starts throwing these module warnings.

I'd definitely appreciate some assistance here.

@davidchai717 davidchai717 added the bug Something isn't working label Sep 25, 2020
@davidchai717 davidchai717 changed the title Vuex would throw warnings about modules get overridden if I call render() in more than one test Vuex would throw warnings about modules getting overridden if I call render() in more than one test Sep 25, 2020
@afontcu
Copy link
Member

afontcu commented Oct 31, 2020

Hi! Sorry this slipped through the cracks. Do you still experience this issue?

Could you share a snippet/codesandbox/repo where the issue could be reproduced? That'd help a lot.

I'd suggest making sure you're not sharing the component instance between tests.

Cheers! 👋

@ITenthusiasm
Copy link
Contributor

@davidchai717 Is the example code you provided (render(component, { state: { foo: true }, modules: {...} })) literally what's in your code base right now? If it is, you're missing the store property in the object scheme. It would be easier if you wrote something like

const store = { state: { foo: true }, modules: {...} };
render(component, { store });

But if that isn't your issue then as afontcu said, a code snippet would be really helpful in getting to the bottom of this.

@afontcu
Copy link
Member

afontcu commented Dec 15, 2020

Closing as we fixed the issue in Discord :) Turns out lodash' merge mutates original source, so the store object was leaking between tests.

@afontcu afontcu closed this as completed Dec 15, 2020
@lukashambsch
Copy link

@afontcu What commit fixed this? Has it been released already? I'm seeing the same issue on 5.6.2 right now.

@afontcu
Copy link
Member

afontcu commented Apr 29, 2021

The fix was to avoid mutating the original store when using lodash merge, and create a new object instead. No fix in VTL was needed 😉

@lukashambsch
Copy link

The fix was to avoid mutating the original store when using lodash merge, and create a new object instead. No fix in VTL was needed 😉

Ahh, I see. Thanks!

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

No branches or pull requests

4 participants