我正在导入一个JS模块并告诉Webpack在我的导入中使用特定的加载器
import animate from 'babel-loader!animateplus';
在客户端(浏览器)上加载文件时,这非常有效。 Webpack使用animateplus
加载babel-loader
模块。
但是,当我在我的测试中导入此模块(使用jest
进行测试)时,它会失败,因为Jest不了解如何加载此模块。
我收到以下错误:
FAIL src/blocks/HomePage/Recurring.client.test.js
● Test suite failed to run
Cannot find module 'babel-loader!animateplus' from 'Recurring.client.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:169:17)
at Object.<anonymous> (src/blocks/HomePage/Recurring.client.js:2:131)
有没有办法告诉Jest使用特定的Webpack加载器加载这个模块?或者更好地模仿这个导入?