Enzyme: update() doesn't update the output

Created on 7 Oct 2016  路  3Comments  路  Source: enzymejs/enzyme

It seems the update function doesn't update, it only outputs the already rendered output.

I use enzyme-to-json to do a "toMatchSnapshot", but when i change the state or simulate an event the snapshot stays the same even when i run component.update();

What i found out is:
In ShallowWrapper.js on line 164 het update function only requests the rendered output
_this2.node = _this2.renderer.getRenderOutput();

when i add
_this2.renderer.render(_this2.node, _this2.options);

It works fine

Need To Reproduce

Most helpful comment

I'm experiencing the same issue.

Even example from documentation doesn't work.

Edit: workaround:

const component = shallow(...);
component.instance().forceUpdate();

All 3 comments

+1

I'm experiencing the same issue.

Even example from documentation doesn't work.

Edit: workaround:

const component = shallow(...);
component.instance().forceUpdate();

@timhonders @dzek69 can either of you provide full repro code?

The line you're referring to seems to be changed in v3, so this might be resolved. I'm going to close it, but will reopen if there's a way to repro.

Was this page helpful?
0 / 5 - 0 ratings