开玩笑:有没有一种方法可以在测试过程中模拟React组件内部的功能

时间:2020-10-30 07:03:20

标签: javascript reactjs jestjs react-testing-library

我有一个像这样的组件

Warning: Cannot update a component XXX while rendering a different component (`Unknown`). To locate the bad setState() call inside `Unknown`,

当我使用Jest和React Testing库测试该组件时。我说错了

setState

CLI突出显示了调用setState的位置。因此,我认为模拟def contact_us(request): if request.method == 'POST': formq = forms.querys(request.POST) if formq.is_valid(): obj = query() obj.name = formq.cleaned_data['your_name'] obj.email = formq.cleaned_data['your_email'] obj.message = formq.cleaned_data['your_message'] obj.save() return redirect(index) else : formq = forms.querys() return render(request, 'home/contact_us.html', {'formq': formq}) 可以解决此问题,但是我没有找到解决方案。

0 个答案:

没有答案