我正在使用jest和酶进行单元测试。但我没有使用react- redux,而是使用umi进行集中的状态管理,但在幕后它只使用redux。现在,当我运行测试文件时,我得到了这个错误
TypeError:(0,_umi.connect)不是函数
101 | };
102 |
> 103 | export default connect(({ login, loading }: ConnectState) => ({
| ^
104 | userLogin: login,
105 | submitting: loading.effects['login/login'],
106 | }))(Login);
at Object.<anonymous> (src/pages/user/login/index.tsx:103:16)
at Object.<anonymous> (src/pages/user/login/login.test.js:6:1)这是我的测试文件
import { shallow, configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });
describe('Login component tests', () => {
let wrapper = shallow(
<LoginContainer.WrappedComponent userLogin={{ status: '', message: '' }} />,
);
})发布于 2020-08-27 15:48:55
我发现有一个已经打开的github问题。问题基本上出在umi库上。我使用了react-redux的connect方法,它工作得很好,但同时,仅仅使用connect方法并不适合多一个库。我一直在使用它,直到它在umi中被修复。
https://github.com/umijs/umi/issues/5138和https://github.com/ant-design/ant-design-pro/issues/6401
https://stackoverflow.com/questions/63597240
复制相似问题