Lifecycle methods are a very power Vue.js feature, that we use all time time.
In this lesson, we’re learning how to test the vue.js lifecycle methods or lifecycle hooks as they’re also called.
The lesson contains examples of how to test the mounted
, beforeDestroy
and destroyed
hook. It should give you the insights to test any lifecycle method you desire.
We will use a spy to test the beforeDestroy
hook. Follow the link to learn more about spies in testing.
You can find the demo on codesandbox