文档说React-admin鼓励e2e而不是单元测试,并且在查看规范文件时,我没有看到通常的存根和模拟来隔离被测代码。此外,当我尝试基于<List />
用数据网格测试自己的List.spec.js
时,出现以下错误。这是仅应由e2es覆盖的示例,还是我可以隔离它,如果可以,怎么办?
BTW:将其包装在act()
中仍然会产生相同的错误。
When testing, code that causes React state updates
should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user
would see in the browser.
Learn more at fb.me/react-wrap-tests-with-act
in List (at mm-services.tsx:7)
in ServiceList (at mm-services.test.tsx:54)
in ThemeProvider (at mm-services.test.tsx:53)
in Router (created by TestContext)
in Provider (created by TestContext)
in TestContext