react-select2-wrapper icon indicating copy to clipboard operation
react-select2-wrapper copied to clipboard

TypeError: this.el.select2 is not a function

Open scottybollinger opened this issue 6 years ago • 9 comments

https://github.com/rkit/react-select2-wrapper/issues/36 is still happening with the latest version 1.0.4-beta.

TypeError: this.el.select2 is not a function when mounting a component in a Jest unit test.

scottybollinger avatar Jul 27 '18 18:07 scottybollinger

I'm having the same problem. This is what i have in my package.json "react-select2-wrapper": "^1.0.4-beta5". Any solution?

Dcuevac93 avatar Sep 10 '18 19:09 Dcuevac93

I'm also having the same issue with the latest 1.0.4-beta6 when mounting a component in a Jest unit test. I'm using Enzyme as well.

TypeError: this.el.select2 is not a function
        at Select2.initSelect2 (node_modules/react-select2-wrapper/lib/components/Select2.js:94:15)
        at Select2.componentDidMount (node_modules/react-select2-wrapper/lib/components/Select2.js:64:12)

CWSites avatar Dec 10 '18 17:12 CWSites

i only got this error when using jest + enzyme

agungyuliaji avatar Dec 20 '18 10:12 agungyuliaji

@rkit any help you could provide here? I've spent a week trying to figure this out, building mocks for select2, importing jquery in different places, etc. This is the only issue preventing me from using your library.

CWSites avatar Dec 20 '18 16:12 CWSites

solved by adding this

global.$ = require('jquery')
global.$.fn.select2 = require('select2')

on jest setup file

agungyuliaji avatar Dec 21 '18 09:12 agungyuliaji

Thank you @agungyuliaji, you're a lifesaver!

CWSites avatar Dec 21 '18 17:12 CWSites

Glad to hear that! anyway it's jest problem. the issue is not related with this plugin.

agungyuliaji avatar Dec 22 '18 13:12 agungyuliaji

the issue was resolved for me when I added global.$ = require('jquery') global.$.fn.select2 = require('select2') to app.js

Thanks @agungyuliaji

syedn avatar May 14 '19 09:05 syedn

@rkit this can be closed.

CWSites avatar Jul 22 '19 19:07 CWSites