From be4681fe7bdc2c2e992393921f0f43c11bbf6c88 Mon Sep 17 00:00:00 2001 From: Wes Harper Date: Thu, 9 Jan 2020 11:59:00 -0700 Subject: [PATCH 1/2] update documentation to include information about lifecycle hooks --- docs/guides/common-tips.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/guides/common-tips.md b/docs/guides/common-tips.md index 7f4766707..bd74b881f 100644 --- a/docs/guides/common-tips.md +++ b/docs/guides/common-tips.md @@ -27,6 +27,10 @@ const wrapper = shallowMount(Component) wrapper.vm // the mounted Vue instance ``` +### Lifecycle Hooks + +When using either the `mount` or `shallowMount` methods, you can expect your component to respond to all lifecycle events. However, it is important to note that `beforeDestroy` and `destroyed` _will not be triggered_ unless the component is manually destroyed using `Wrapper.destroy()`. + ### Writing asynchronous tests using `nextTick` (new) By default, Vue batches updates to run asynchronously (on the next "tick"). This is to prevent unnecessary DOM re-renders, and watcher computations ([see the docs](https://vuejs.org/v2/guide/reactivity.html#Async-Update-Queue) for more details). From 3652a531d52920e6551c2faa52cf044d4f711dd1 Mon Sep 17 00:00:00 2001 From: Wes Harper Date: Thu, 9 Jan 2020 12:04:35 -0700 Subject: [PATCH 2/2] add additional clarifying comments --- docs/guides/common-tips.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/guides/common-tips.md b/docs/guides/common-tips.md index bd74b881f..1fb642905 100644 --- a/docs/guides/common-tips.md +++ b/docs/guides/common-tips.md @@ -31,6 +31,8 @@ wrapper.vm // the mounted Vue instance When using either the `mount` or `shallowMount` methods, you can expect your component to respond to all lifecycle events. However, it is important to note that `beforeDestroy` and `destroyed` _will not be triggered_ unless the component is manually destroyed using `Wrapper.destroy()`. +Additionally, the component will not be automatically destroyed at the end of each spec, and it is up to the user to stub or manually clean up tasks that will continue to run (`setInterval` or `setTimeout`, for example) before the end of each spec. + ### Writing asynchronous tests using `nextTick` (new) By default, Vue batches updates to run asynchronously (on the next "tick"). This is to prevent unnecessary DOM re-renders, and watcher computations ([see the docs](https://vuejs.org/v2/guide/reactivity.html#Async-Update-Queue) for more details).