2

I am writing test case using react-testing-library

while running test case I am getting TypeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node'.

TypeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node'.

      285 |
    > 286 |                         if (!e.currentTarget.contains(e.relatedTarget)) {
          |                                              ^
      287 |                             dispatch("MOUSE_OUT");
      288 |                             onMouseLeave?.(e);
      289 |                         }

on mouseleave i am calling handleMouseLeave

      const handleMouseLeave = React.useCallback(
                    e => {
                        if (!e.currentTarget.contains(e.relatedTarget)) {
                            dispatch("MOUSE_OUT");
                            onMouseLeave?.(e);
                        }
                    },
                    [dispatch, onMouseLeave]
                );

and in test case am firing mouseLeave event

        fireEvent.mouseLeave(getAllByTestId("row")[0]);

and after event fire I am getting error

Saurabh Singh
  • 197
  • 1
  • 6

0 Answers0