问题描述
我正在对我的 redux 表单进行一些单元测试,但遇到了很多问题。目前我的测试看起来像这样
descendant
我使用的是材质 ui,因此使用了 createShallow。当我调试浅渲染时
describe('testing ForgotPassword functionality',() => {
let ForgotPasswordForm;
let defaultProps = {
handleSubmit: (fn) => fn
}
let shallow;
let props = {
forgotPassword: jest.fn()
}
let store = createStore(combineReducers({ form: formReducer,auth: authReducer }));
beforeEach(() => {
shallow = createShallow({ dive: true })
ForgotPasswordForm = shallow(
<Provider store={store}>
<ForgotPassword {...defaultProps} {...props} />
</Provider>
);
});
it('ForgotPassword renders correctly with email',() => {
expect(ForgotPasswordForm).toMatchSnapshot();
});
it('check event on `Submit` button',() => {
console.log(ForgotPasswordForm.debug())
const emailField = ForgotPasswordForm.find('input[name="email"]');
emailField.simulate('change',{ target: {value: 'test@123.com'} });
const submitButton = ForgotPasswordForm.find(Button).find('button');
submitButton.simulate('click').simulate('submit');
expect(defaultProps.handleSubmit).toHaveBeenCalledTimes(10);
});
})
这给我尝试进行查找带来了问题,因为它找不到 html。我一定在这里遗漏了一些明显的东西。我曾尝试再次潜水,但出现错误
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)