Skip to content

Instantly share code, notes, and snippets.

@unfalse
Last active December 11, 2017 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unfalse/c20b3dc396bde5a1473f242ec337b7d8 to your computer and use it in GitHub Desktop.
Save unfalse/c20b3dc396bde5a1473f242ec337b7d8 to your computer and use it in GitHub Desktop.
Changing select value not working on enzyme react test
it('enter valid data for connection; enable proxy; check if button is disabled', () => {
const component = getComponent(mount); // mount from enzyme
enterCredentials(component);
const proxySelect = component.find('select');
// currently tried these variants:
proxySelect.simulate('change', { target: { value: true } } );
// component.find('select').simulate('select', true);
// component.find('select').simulate('select', 'Yes');
// component.find('select').simulate('change', { target: { value: true } } );
// /* Mutating: */
// proxySelect.node.selectedIndex = 1;
//
// Producing this error:
//
// Attempted to access ReactWrapper::node, which was previously a private property on
// Enzyme ReactWrapper instances, but is no longer and should not be relied upon.
// Consider using the getElement() method instead.
//
// at ReactWrapper.get (node_modules/enzyme/build/ReactWrapper.js:1689:15)
expect(proxySelect.prop('value')).toBe(true);
expect(component.find('button').prop('disabled')).toBe(false);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment