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

feat: Introduce enableAutoDestroy() helper function #1245

Merged
merged 6 commits into from
Jan 13, 2020
Merged

feat: Introduce enableAutoDestroy() helper function #1245

merged 6 commits into from
Jan 13, 2020

Conversation

winniehell
Copy link
Contributor

This introduces a new enableAutoDestroy() helper function which allows to automatically call wrapper.destroy() by passing in a custom hook function (such as afterEach).

closes #1236

@winniehell
Copy link
Contributor Author

@souldzin can I ask you to take a look at this?

Copy link
Contributor Author

@winniehell winniehell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pushed the following changes:

  • simplified the tests a little
  • added a guard against calling the helper twice
  • made the wrapper instances scoped inside Wrapper instead of the module to allow resetting them (for example in unit tests)

packages/test-utils/src/wrapper.js Outdated Show resolved Hide resolved
packages/test-utils/src/wrapper.js Outdated Show resolved Hide resolved
Copy link
Contributor

@souldzin souldzin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the ping and iterating on this @winniehell! Back to you ⚽

docs/api/enableAutoDestroy.md Outdated Show resolved Hide resolved
packages/test-utils/src/wrapper.js Outdated Show resolved Hide resolved
packages/test-utils/src/wrapper.js Outdated Show resolved Hide resolved
packages/test-utils/src/wrapper.js Outdated Show resolved Hide resolved
packages/test-utils/src/wrapper.js Outdated Show resolved Hide resolved
test/specs/wrapper.spec.js Show resolved Hide resolved
@winniehell
Copy link
Contributor Author

It looks like we want to solve #1224 and #1135 first. 😃

Copy link
Contributor

@dobromir-hristov dobromir-hristov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, two small comments.

packages/test-utils/src/create-wrapper.js Show resolved Hide resolved
packages/test-utils/src/auto-destroy.js Outdated Show resolved Hide resolved
packages/test-utils/src/create-wrapper.js Show resolved Hide resolved
Copy link
Contributor

@dobromir-hristov dobromir-hristov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should document the resetAutoDestroyState? I am not sure if it makes sense for ppl to need it though 😆

@lmiller1990
Copy link
Member

I think if we have the feature, it should be documented. Maybe a sentence or two explaining when/why it's useful?

The code seems good, no problems here 👍

Copy link
Member

@afontcu afontcu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

Regarding documenting resetAutoDestroyState, we should do so, but I wouldn't stress it too much. Maybe just mention it in the enableAutoDestroy section?

@dobromir-hristov
Copy link
Contributor

Same, just mention it exists. Maybe add them to the API docs, because I find myself search there more, than in the guides.

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

Successfully merging this pull request may close these issues.

Support cleaning up wrappers automagically
5 participants