Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: this.el.select2 is not a function #83

Open
scottybollinger opened this issue Jul 27, 2018 · 9 comments
Open

TypeError: this.el.select2 is not a function #83

scottybollinger opened this issue Jul 27, 2018 · 9 comments

Comments

@scottybollinger
Copy link

#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.

@Dcuevac93
Copy link

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

@CWSites
Copy link

CWSites commented Dec 10, 2018

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)

@agungyuliaji
Copy link

i only got this error when using jest + enzyme

@CWSites
Copy link

CWSites commented Dec 20, 2018

@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.

@agungyuliaji
Copy link

solved by adding this

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

on jest setup file

@CWSites
Copy link

CWSites commented Dec 21, 2018

Thank you @agungyuliaji, you're a lifesaver!

@agungyuliaji
Copy link

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

@syedn
Copy link

syedn commented May 14, 2019

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

Thanks @agungyuliaji

@CWSites
Copy link

CWSites commented Jul 22, 2019

@rkit this can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants