我正在使用JEST和RESPECT测试库.当我try 呈现组件时,我无法对其进行测试.你们能告诉我做这个的正确方法吗?
it("Render PopUp Properly", () => {
const props = {
setIsOpen: jest.fn(),
children: <div>Test</div>,
};
const {getByTestId}= render(<Popup isOpen={true} {...props} />);
expect(screen.getByTestId("popup-component")).toBeInTheDocument();
});
出现以下错误:
PopUp › Render PopUp Properly
Target container is not a DOM element.
13 | }
14 |
> 15 | return createPortal(
| ^
16 | <motion.div
17 | data-testid="blur-bg"
18 | initial={{
我希望我的组件能够正确呈现,但得到的却是那个错误.