【发布时间】:2019-11-22 07:15:47
【问题描述】:
我正在尝试测试具有包含 react-intersection-observer 的子组件的组件,但我总是收到错误
我尝试导入库,但仍然失败。 这是初步测试
beforeEach(() => {
testContainer = document.createElement("div");
document.body.appendChild(testContainer);
subject = memoize(() =>
mount(<FilterNav {...props} />, { attachTo: testContainer })
);
});
afterEach(() => {
testContainer.remove();
});
context("the main filter is shown initially", () => {
it("sets focus on the primary filter", () => {
subject();
const input = testContainer.querySelector(".main-input");
expect(document.activeElement).toEqual(input);
});
我收到此错误 -> 未捕获 [ReferenceError: IntersectionObserver is not defined]
有什么方法可以模拟 IntersectionObserver?
谢谢
【问题讨论】:
标签: javascript reactjs jestjs