reactjs - How to include javascript files when testing React components? -


i'm writing test react component uses selectpicker javascript library. here's mount method:

componentdidmount() {  const selectcontrol = $(this.refs.selectname);  selectcontrol.selectpicker('refresh'); } 

it works fine since wrap javascript created webpack in rails environment includes selectpicker.js file in assets, test wrote doesn't know included file , throws error:

typeerror: selectcontrol.selectpicker not function

what best architecture here? should component including javascript file? can include js file in test?

any appreciated.

what want test exactly?

if want test rendering of component without carrying if selectpicker jquery plugin has been applied, can use library enzyme (from airbnb) can shallow rendering without mounting component


Popular posts from this blog

node.js - How do I prevent MongoDB replica set from querying the primary? -

java - Cannot send AES encrypted messages of over 47 characters -

php - Angularjs http.delete is not working after deploying project on server -