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