-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
测试umi页面报错: (0 , _umi.connect) is not a function #5138
Comments
I've come across this issue also trying to write a test for an ant-design-pro component. Is there an example of how the dva-plugin needs to be initialised within a test in order to make this work ? It's a pity to not have unit tests for |
` FAIL src/pages/user/Login/index.test.tsx (6.028 s)
|
A quick solution: |
I got the same problem, then I found a solution to reslove it. |
Thanks @AsserHong, however I still got the issue. Any other ideas? |
@sajjadshahi hi, I think u still got the issue because the .umi folder is not exist in ur test enviroment. So, I suggest u can try to mock the connect method with jest, like this |
@AsserHong I've been trying this too. But there are many modules there in Ant Design Pro which I should mock following this solution. As @vinzid mentioned above, As well, testing the whole redux is my approach. We might need to check if an action is properly dispatched and changed the store in our test case. I wish there could have been a good boilerplate with some tests. |
@AsserHong Where should I put this codes? |
in the jest.config.js file |
@AsserHong Pi! I have already fixed this problem by this way. I put codes in the setupfiles. |
I have already fixed this problem by this way. I put codes in the setupfiles or the test file. If you need the function or attribute, just rewrite it! Following it's feature! |
That's really a good solution |
Same question, I am focus the issue too. Error like this:
I have tried import umi by Hope someone can give some suggestions~ |
The solution
Bellow is my testing
So, I guess the
As I said, And now I have a temp solution, just for developing test
change Now, you can pass all your jest blocking code cause like this
|
邮件我已收到,谢谢!
|
What happens?
umi项目,当我用enzyme 进行单元测试时,引入了使用umi.connect 包裹的组件,会报错,无法进行测试
最小可复现仓库
import React from 'react';
import { shallow, configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { matchMedia } from '@/utils/utilsTest';
import workbench from './index';
configure({ adapter: new Adapter() });
console.log(workbench, 999)
beforeAll(() => {
matchMedia();
});
describe('', () => {
it('渲染基本UI', () => {
// const $ = shallow();
// expect($.find('Select').length).toBe(1);
});
});
复现步骤,错误日志以及相关配置
● Test suite failed to run
相关环境信息
The text was updated successfully, but these errors were encountered: