In NodeJS - Simplest possible Jquery Mock
When required to test a Jquery plugin, on the server, that is not doing any DOM manipulation, you might want to simply mock the jQuery extension point:
var JQuery = function(){};
global.jQuery = global.$ = new JQuery();
global.jQuery.fn = JQuery.prototype;
With above lines in place, you can now simple create your plugin:
(function($){
$.fn.myExtension=function(params){
//Your code here
}
})(jQuery);
This assumes you are not reusing any Jquery core methods.
Written by Avner Cohen
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Jquery
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#