我的应用程序中有一个(编写得相当糟糕) javascript组件,它处理无限滚动分页,我试图重写它以使用IntersectionObserver,正如描述的,但是我在测试它时遇到了问题。handle the infinite scroll var io = new IntersectionObserver);
//Do some assertions about the state after the callback
我使用@testing-library/react 12.1.4和@testing-library/jest-dom 5.16.3编写了一些单元测试,以使组件更安全。ReferenceError: IntersectionObserver is not defined observe: () => null interface
我用创建了一个基本的NextJS应用程序,然后添加了用于测试的Jest。但是,我得到的错误是“在测试中对图像的更新没有包装在act(.)中”在我的Jest测试中。我在这里包含了Jest测试和组件中有问题的部分:import Head from 'next/head'import { render, act } from