在import语句中指定时,告诉Jest使用webpack加载器

时间:2018-04-03 11:20:10

标签: webpack jestjs webpack-2

我正在导入一个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加载器加载这个模块?或者更好地模仿这个导入?

0 个答案:

没有答案