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

Support cleaning up wrappers automagically #1236

Closed
ghost opened this issue May 20, 2019 · 4 comments · Fixed by #1245
Closed

Support cleaning up wrappers automagically #1236

ghost opened this issue May 20, 2019 · 4 comments · Fixed by #1245

Comments

@ghost
Copy link

ghost commented May 20, 2019

What problem does this feature solve?

Currently it is necessary to call wrapper.destroy() / wrapper.vm.$destroy() manually. Forgetting to do so may result in difficult to track down side effects and performance degradation (especially when not mocking Vuex).

What does the proposed API look like?

Introduce a new enableAutoDestroy() helper which accepts a hook function such as afterEach() to call wrapper.destroy() as callback.

@winniehell
Copy link
Contributor

@eddyerburgh I am interested in implementing this. Would you accept a pull request? 😃

@eddyerburgh
Copy link
Member

Yep 😄

@winniehell
Copy link
Contributor

As I realized from @souldzin's comment on the pull request (#1240 (comment)), the API proposed here does not work. For a hook like afterEach we want to make sure it is only called exactly once. I'm not sure how we would ensure that when passing it as an config option.

Instead we could provide an enableAutoDestroy() function that accepts the hook function as parameter. We could then rely on that function being called only once (in test setup).

@winniehell
Copy link
Contributor

I have updated the description now with the new suggested API and will create a new pull request tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants