javascript - How to unit test if a select element in React has focus using Enzyme? -


i have dropdown component in react renders select element label , options. here test looks like:

import react 'react'; import { shallow, mount } 'enzyme'; import dropdown './dropdown';  describe('dropdown', () => {   it('should focused on label click', () => {     const wrapper = mount(       <div>         <label htmlfor={'dropdownid'}>sort by: </label>         <dropdown           id="dropdownid"           options={[             { key: '', display: 'please select value' },             { key: 'nj', display: 'new jersey' },             { key: 'ny', display: 'new york' },           ]}         />       </div>,     );      const dropdownlabel = wrapper.find('label');     const dropdownselect = wrapper.find(dropdown);      dropdownlabel.simulate('click', {});     expect(dropdownselect.is(':focus')).tobe(true);   }); }); 

i'm trying simulate click on label test if select element have focus, getting following error: typeerror: enzyme received pseudo-class css selector (':focus') not support in tests.webpack.js

i'm using phantomjs version 2.1.1

is there way replicate purpose of test, without using css pseudo selectors?

thanks.

you should consider using different unit testing suites.

https://github.com/airbnb/enzyme/issues/703


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -