react-cosmos: Using `set` to set reduxState in test context doesn't update the actual st.

What’s up?

Setting reduxState in test context doesn’t update the actual state.

Mkay, tell me more…

Turns out this test from the docs doesn’t actually work…

test('responds to new state', () => {
  const newState = { showWarning: true };
  set('reduxState', newState);
  expect(getWrapper('.btn').hasClass('warning')).toBeTruthy();
});

This is my bad for not testing it in my other PR the other day. Once the store has been created in the redux-proxy, it takes over management of the store state (as it should) and doesn’t do anything with an updated fixture props. I tried setting the ‘alwaysCreateStore’ option on the proxy but that doesn’t work (it only does it on the constructor, not componendDidUpdate.

Now I’m also not sure that the other proxies also respond to the fixture being updated as a lifecycle change and respond accordingly.

I’m wondering what the best way to go about doing this would be? Happy to help (since I created a buggy ‘feature’).

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (15 by maintainers)

Commits related to this issue

Most upvoted comments

This happens to me in non-test context aswell. If I supply a state or change the state in the component itself or in the code window it doesn’t seem to update. If I disable the redux proxy however, all seems to work fine.

Passing disableLocalState to the redux proxy doesn’t work either.

Yep, i’ve got it up and going but need to add a couple more tests, thanks for the help! Stay tuned!