简体   繁体   中英

jquery.mockjax using with Webpack needing shim

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.

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=>""']
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM