Can't run unit test same as in the example docs
See original GitHub issueWhen I run my test I see the next:
Code of the test is pretty mush simple.
import React from 'react'
import { shallow } from 'enzyme';
import OrganizationSelect from './index';
it('renders Dashboard', () => {
// Use the wrapped components
const wrapper = shallow(<OrganizationSelect.WrappedComponent user={{ list: [] }} loading={{user: []}}/>);
// const wrapper = shallow(<OrganizationSelect/>);
expect(wrapper).toBe()
});
Code of the component
import React from 'react';
import { connect } from 'umi';
import { Select } from 'antd';
import styles from './index.less';
const { Option } = Select;
const OrganizationSelect = ({ dispatch, currentUser, loading, ...props }) => {
const handleChange = async (code) => {
await dispatch({
type: 'user/setLastSelectedOrganization',
payload: code,
});
await dispatch({
type: 'user/fetchCurrent',
});
};
if (!loading) {
return (
<Select
className={styles.organizationSelect}
defaultValue={
currentUser.last_selected_organization
? currentUser.last_selected_organization.code
: null
}
onChange={handleChange}
>
{currentUser.organizations.map(({ name, code }, i) => (
<Option key={code} value={code}>
{name}
</Option>
))}
</Select>
);
}
return <></>;
};
export default connect(({ user, loading }) => ({
currentUser: user.currentUser,
loading: loading.models.user,
}))(OrganizationSelect);
How I can fix this error and make my test run? Can you help me, please? Many thanks for the answers in English!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9
Top Results From Across the Web
Run unit tests with Test Explorer - Visual Studio (Windows)
Test Explorer can run tests from multiple test projects in a solution and from test classes that are part of the production code...
Read more >Run tests | IntelliJ IDEA Documentation - JetBrains
To run all tests in a folder, select this folder in the Project tool window and press Ctrl+Shift+F10 or select Run Tests in...
Read more >Should I document my unit test methods? - Stack Overflow
Agreed w/ Vinko: sometimes it doesn't work that well, like when you do data-driven tests, and use the same unit test template, passing...
Read more >Unit testing | Replit Docs
Unit testing is great for more complicated testing scenarios. For example, when you need to test that functions return specific values based on ......
Read more >unittest — Unit testing framework — Python 3.11.1 ...
Basic example¶. The unittest module provides a rich set of tools for constructing and running tests. This section demonstrates that a small subset...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
我们很关注这个问题,但是它已经很长时间没有回应。我们会暂时关闭它 —— We are very concerned about this issue, but it has not responded for a long time. We will temporarily close it
the same issue. Unhandled Rejection (TypeError): (0 , _umi.connect) is not a function ./src/layouts/BasicLayout.tsx src/layouts/BasicLayout.tsx:174