Enzyme Unit tests with Webpack Externals

橙三吉。 提交于 2019-12-24 01:24:00

问题


I'm currently testing a component that relies on a an external script with webpack externals.

DBPanel.js:

import React, { PureComponent } from 'react';
import $ from 'jquery';

And the webpack externals file looks like this:

webpack.config.js:

externals: {
    jquery: "jQuery",
    Materialize: "Materialize"
}

When I import the the file in my test import DBPanel from '../components/DBPanel'; I get this error:

Error: Cannot find module 'jquery'

来源:https://stackoverflow.com/questions/45724728/enzyme-unit-tests-with-webpack-externals

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!