srigar / multiselect-react-dropdown

React multiselect dropdown with search and various options
https://10xn41w767.codesandbox.io/
MIT License
200 stars 114 forks source link

Error: Uncaught [TypeError: Cannot read property 'addEventListener' of null] thrown when using component in tests #252

Open alex-akanthas opened 1 year ago

alex-akanthas commented 1 year ago

Reopening https://github.com/srigar/multiselect-react-dropdown/issues/78

@srigar I'm still getting this error with version 2.0.25 and jest

/**
 * @jest-environment jsdom
 */

import renderer from 'react-test-renderer';
import { Multiselect } from 'multiselect-react-dropdown';

it('multiselect renders', () => {
    let state = {
        options: [{name: 'Option 1', id: 1},{name: 'Option 2', id: 2}]
    };

  const tree = renderer
    .create(<Multiselect
            options={state.options} // Options to display in the dropdown
            displayValue="name" // Property name to display in the dropdown options
      />
)
    .toJSON();
  expect(tree).toMatchSnapshot();
});

Any help would be much appreciated. The component itself works great with some nice fixes being observed after we upgraded from 1.6 to 2.0.25 :-)

alex-akanthas commented 1 year ago

And please let me know if I have done something wrong