Skip to content

Testing with react testing library (rtl) #1258

Answered by tomtobac
tomtobac asked this question in Q&A
Discussion options

You must be logged in to vote

Sorry, it can be closed. I found the mistake:

const Test = ({ fn }: { fn: VoidFunction }) => {
  const { getInputProps, getRootProps } = useDropzone({
    onDrop: fn,
  });
  return (
    <div role="presentation" {...getRootProps}> {/* <---- it's a function, typescript won't complain and it should be called {...getRootProps() */}
      <input {...getInputProps} /> {/* <---- it's a function, typescript won't complain and it should be called {...getInputProps()} */}
    </div>
  );
};

Also in my test im not awaiting basically because typescript complains about it (not necessary) and I remove it. Same with act. If you ignore this warning it should work.

await act(() => fireEvent.drop(dropzone, 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tomtobac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant