如何在反应测试库中模拟 Document.getElementById

问题描述 投票:0回答:0

我正在使用无头 UI

Dialog, Transition 
组件,我在使用反应测试库编写测试用例
Cannot read properties of null (reading 'getElementById')
时遇到以下错误所以我如何在反应测试库中模拟 Document.getElementByID?

describe('Testing  Component', () => {
  test('It should render component', () => {
    render(
      <Edit
        form={form}
        phoneNumber={phoneNumber}
        appId={appId}
      />,
    );
    const isItRendered = screen.getByTestId('lending_editAPP');
    expect(isItRendered).toBeInTheDocument();
  });
});
javascript reactjs dom react-testing-library
© www.soinside.com 2019 - 2024. All rights reserved.