I have a very simple React mixin which uses jQuery to trigger an event
MyMixin = {
trackStructEvent: function () {
args = Array.prototype.slice.call(arguments);
$('body').trigger('myEvent', args);
}
module.exports = MyMixin
This is imported into the main site as part of a new set of components using browserify. As the main site holding these components will always include jQuery, I don't want to require jQuery with browserify, as it will be duplicated.
This isn't an issue in terms of behaviour - however it causes problems when running jest to unit test the components using this mixin throwing the error.
ReferenceError: $ is not defined
I know I can fix this by including jQuery through browserify, but that will load 2 copies into my site.
Is there any way in jest to tell my react component that jQuery already exists on the window and not to worry about it?