Shallow render - bypass lifecycle hooks
See original GitHub issueFirst off super awesome stuff on the latest 2.1.0 release and shallow rendering 🙌 Been looking forward to that and thanks for all the effort in creating avoriaz!
I just checked out the shallow rendering, and for a case where a child component has some lifecycle hook, it will still get executed during test. For example a child component dispatching a vuex action on mount:
export default {
name: 'SomeChildComponent',
mounted() {
this.$store.dispatch('fetchUsers');
}
};
This is expected, but would it be worth having a way to optionally bypass the lifecycle hooks so that testing the parent doesn’t care about any of these potentially side effects?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top Results From Across the Web
React shallow render lifecycle breakdown · GitHub
TLDR; shallow rendering only invokes the following lifecycle hooks (in order):. getDefaultProps; getInitialState; componentWillMount stops here until re- ...
Read more >Shallow Render
On every render, your component will go through the normal component lifecycle (eg: ngOnInit , ngOnChange , etc.) via a call to fixture.detectChanges()...
Read more >Hooks FAQ - React
Do Hooks replace render props and higher-order components? What do Hooks mean for popular APIs like Redux connect() and React Router? Do Hooks...
Read more >Migrating from shallow rendering react components to explicit ...
Testing React using shallow rendering has a bunch of problems with regards to testing implementation details. Let's see how we can use Jest ......
Read more >reactjs - With useEffect, how can I skip applying an effect upon ...
The useEffect hook will be run after the render has completed and, as you've pointed out, it's run with every render - unless...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
fixed in release 2.1.1 see c39ed7f37b7e90a6aff97781ca9537de55ef9de6
This should be fixed in 2.1.1 👍