question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Shallow render - bypass lifecycle hooks

See original GitHub issue

First 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
crcatalacommented, Jun 20, 2017

fixed in release 2.1.1 see c39ed7f37b7e90a6aff97781ca9537de55ef9de6

1reaction
eddyerburghcommented, Jun 20, 2017

This should be fixed in 2.1.1 👍

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found