2

I am using mocha for unit testing.I have used foundation library and have initialized it in componentDidMount() and componentDidUpdate() as below

componentDidMount(){
  $("#element").foundation();
}

In testutils setup file i have initialized

global.jQuery = require('../node_modules/jquery/dist/jquery');
global.$ = global.jQuery;
global.window.jQuery = global.jQuery;
global.window.$ = global.jQuery;
global.Foundation=require('../node_modules/foundation-sites/dist/foundation');
global.window.Foundation=global.Foundation

I am getting this error

D:\xxxx\xxxxx\xxxx\node_modules\foundation-sites\dist\foundation.js:391
  Foundation.Box = {
  ^

ReferenceError: Foundation is not defined

Please let me know how to import foundation and mock .foundation() method.

Sweety
  • 33
  • 1
  • 5
  • Not related to the question, but It does not seem to be a good idea to use jQuery in react. jQuery works on DOM manipulation using event handlers. React works on state manipulation and then render UI based on new state. Mixing this will give unexpected results. You can also take a look at https://www.npmjs.com/package/react-foundation – anoop Oct 15 '16 at 02:16

0 Answers0