-
-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot read properties of null (reading 'off')
during mount when running tests for a wrapper component
#81
Comments
TypeError: Cannot read properties of null (reading 'off')
during mount when running tests for a wrapper component
Wrapper components are definitely encouraged since this is an unopinionated and unstyled component! Everyone's got their own UI components, UX flows, and CSS styles, so I think composition for a more specific use-case is good separation of concerns (while this component handles the generic use-case).
Hard to tell without a reproduction as there's a number of moving pieces here.
|
Looking at the stack trace a bit more, EDIT: Hmmm... it is possible you're running into the exact situation discussed in the TS rewrite review: #42 (comment) . |
@agilgur5 thank you for the quick response! I am using |
Mmm A minimal reproduction would help here. Especially your |
I am working on getting a repro ready to go. Unfortunately, the project I'm working on is closed source. I am trying to get a codesandbox example but am running into with Here it is if you want to give it a try: https://codesandbox.io/s/react-17-forked-y43gl3?file=/src/tests/Signature.spec.js |
Yea this is probably the crux of the issue -- the
You're using CRA for this CodeSandbox, so you may very well be running into hustcc/jest-canvas-mock#72 . I did create a more minimal StackBlitz project for this instead, and the tests pass fine there: https://stackblitz.com/edit/rsc-issue-81?file=index.spec.js . |
Fun fact, apparently I ran into the |
Hello and thank you so much for your work on this project! I am creating a wrapper around the
react-signature-canvas
and am working on writing jest tests for it withtesting-libarary/react
. I am simply trying to mount it to ensure it displays properly and am receiving the following error. I'm not passing anything to it besides aref
(created withuseRef
); I'm not even touchingcanvasProps
(at this point). I am rendering the parent<div />
with adata-testid
so that I can grab hold of it in testing-library.Test Code:
(
Signature
is my wrapper component, this is what I'm actually rendering<SignatureCanvas ref={canvasRef} {...canvasAttributes} />
butcanvasAttributes
isnull
in my test above.)Stack trace:
Rendering in the browser seems to work. Any suggestions as to what I'm doing wrong or is this a bug?
The text was updated successfully, but these errors were encountered: