4

Has anyone used mockjax for jasmine unit tests with webpack? I keep getting $.mockjax is undefined. It has something to do with

// NOTE: To use Mockjax as a Node module you MUST provide the factory with // a valid version of jQuery and a window object (the global scope): // var mockjax = require('jquery.mockjax')(jQuery, window);

but I can't use require in an AMD module. I've attempted to use a shim and the import-loader with webpack but I may have done something wrong because I don't fully understand the problem.

Jordan Kasper
  • 13,153
  • 3
  • 36
  • 55
Craig
  • 55
  • 3

1 Answers1

0

This is pretty old, but I missed it because of the lack of the mockjax tag! Anyway, this should have been resolved in PR #284. There was an issue about this with some suggestions, specifically:

{
    test: require.resolve('jquery-mockjax/dist/jquery.mockjax.js'),
    use: ['imports-loader?this=>window,exports=>""']
}
Jordan Kasper
  • 13,153
  • 3
  • 36
  • 55