我正在尝试使用带有酶的开玩笑来进行测试。
这是我的测试
import 'jsdom-global/register';
import React from 'react';
import { mount } from 'enzyme';
import { Provider } from "react-redux";
import configureMockStore from "redux-mock-store";
import WorkOutForm from './workOutForm';
const mockStore = configureMockStore();
const store = mockStore({});
let wrapper;
beforeEach(() => {
wrapper = mount(
<Provider store={store}>
<WorkOutForm />
</Provider>);
});
describe('WorkOutForm', () => {
it('should start a new workoutForm', () => {
expect(wrapper).toMatchSnapshot()})
})
但是我收到:
TypeError:无法读取未定义的属性'tempoGasto'
86 | } 87 | > 88 | const mapStateToProps = state => ({tempoGasto: state.workout.tempoGasto, tipoTarefa: state.workout.tipoTarefa, data:
state.workout.data}) | ^ 89 | const mapDispatchToProps =调度=> 90 | bindActionCreators({addworkout,searchWorkout,changeTempoGasto,changeHoraTarefaMask,changeDataTarefaMask, changeTipoTarefa,changeDataTarefa},调度) 91 |导出默认的connect(mapStateToProps,mapDispatchToProps)(WorkOutForm)
在组件中,我正在使用export default connect
传递我的mapstateprops
和我在bindActionCreator
中的动作。
我如何安装此组件?
试图导入动作changeHoraTarefaMask并做出一个wrapper.changeHoraTarefaMask('11:11')
,但我遇到了同样的错误