Skip to content Skip to sidebar Skip to footer

Load Jquery Into Mocha Test For React App

I've created a Mocha test setup similar to this tutorial outlined here: https://github.com/jesstelford/react-testing-mocha-jsdom. I'm wondering how I can load in jQuery into this

Solution 1:

This is a pattern that has worked for me for certain jquery methods in mocha, I'm not sure it'll work for ajax but give it a shot and let me know.

import jsdom from 'jsdom'
import _$ from 'jquery'

global.document = jsdom.jsdom('<!doctype html><html><body></body></html>')
global.window = global.document.defaultView
const $ = _$(global.window)

Post a Comment for "Load Jquery Into Mocha Test For React App"