-
Notifications
You must be signed in to change notification settings - Fork 668
Error: [vue-test-utils]: enableAutoDestroy cannot be called more than once #1638
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
Comments
Hi! Thanks for the issue. Which test runner are you using? I wonder if this is test-runner specific. Are you interested in investigating making a PR by any chance? |
@mariadb-ThienLy I believe this is intended behavior - you can register @lmiller1990 WDYT of making |
@lmiller1990 exactly, I'll make a PR |
author of #1245 here 👋
Yes, to some degree it was intended because you don't run into the issue in an isolated test environment such as Jest. Resetting the hook callback is a bit complicated. No test framework I know of allows to disable callbacks you once passed to We could replace this vue-test-utils/packages/test-utils/src/auto-destroy.js Lines 21 to 30 in 6e3e4e5
with const callback = () = {
// ...
}
hook(() => callback());
const disable = () => {
callback = () => {};
isEnabled = false;
};
return disable; but it's not extremely beautiful as (the empty) callback will still be called for every test run. |
I believe this one could be closed - there is |
@xanf Calling |
@winniehell correct me if I'm wrong https://github.com/vuejs/vue-test-utils/blob/dev/packages/test-utils/src/auto-destroy.js#L10 will allow me to reinstall |
@xanf yes, more precisely: It can be called more than once but the behavior would be surprising. For example enableAutoDestroy(afterEach);
resetAutoDestroyState();
enableAutoDestroy(afterAll); would destroy the wrappers in |
enableAutoDestroy doesn't work as expected
Basically I have many ***spec.js files. There are two files that I call this helper, it prompts error immediately after I run the all tests.
Steps to reproduce
Create two dummy unit tests files. e.g. Hello.spec.js and Dummy.spec.js and calls
enableAutoDestroy(afterEach)
Expected behaviour
Should work normal as using wrapper.destroy() in afterEach hooks
Actual behaviour
The text was updated successfully, but these errors were encountered: