似乎如果你不将Material-UI样式表注入到jest/react-testing-library测试中,那么jsdom将无法从你的组件中获得正确的样式(例如,运行getComputedStyle(component如何正确设置jest/react- test -library测试,以便将样式正确地注入到测试中?我已经将组件包装在一个主题提供程序中,可以很好地工作。
我是个新手,对所有的测试库都很困惑。我让我的测试代码正常工作,但为了使用它的toMatchSnapshot(),必须从react- test -renderer调用create(),并且为了使用它的断言,必须从@testing-libraryimport {render} from '@testing-library/react';
import {act, create} from 'reac
我正在使用react-testing -library测试我的组件,并且测试工作正常。我就是摆脱不了这个警告,fireEvent应该被包装在开箱即用的行为中,但我试图再次包装它,它没有帮助。这是我的测试用例。When testing, code that causes React state updates should be wrapped into act(...):
act(() => {