Babel How to ignore jquery

时间:2017-11-08 22:04:13

标签: ruby-on-rails reactjs mocha babel

I'm using mocha with babel:register to test my react code.

mocha --compilers js:babel-register

In my react components (not the test), I'm using jquery with $ symbol and the test is complaining about $ is not a function. How can I ignore this?

The reason I'm doing this but not using import $ from 'jquery' is because rails has jquery bundled so I don't want to duplicate it.

1 个答案:

答案 0 :(得分:0)

挣扎之后。您可以在全局变量中设置jQuery或$。

import jquery from 'jquery';
global.$ = jquery;