-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[Bug]: Jest unit test fails for useEditor() #5108
Comments
I am also seeing this issue. Pretty sure it was due to this change in 2.3.1: #4856 Specifically removal of this line Before that the setEditor was updating state and causing a rerender, and then returning a not null editor. (I tried copy pasting the old version of the code with the setEditor and my tests start working again) @svenadlung if you could explain why this is not an issue in the production code, it would help us understand what we need to emulate in our tests. |
SSR is the reason behind this. Without a document the editor can fail since it is expected to run within the browser. With the new react binding and But do note that any bugs that happen on the server are not going to be prioritized as the editor is not meant to be ran there and could have incompatibilities |
Sorry confused, but our tests were running with jest-dom, so wouldn't that mean it did have a "browser", and was not doing SSR? (our team can't upgrade React so we can't use the new stuff 😅 ) |
My comment around SSR was the reason why we changed jest-dom emulates a browser, but is not an actual instance, I'm unsure if it can even declare a global document instance or not, in any case tiptap is not really meant to be running in a node instance. |
Which packages did you experience the bug in?
What Tiptap version are you using?
2.3.0
What’s the bug you are facing?
I've upgraded TipTap from 2.1.13 to 2.3.0 and now my unit tests are failing. After inspection, it seems that useEditor always returns
null
.I've tried commenting out all my custom code and using a very basic example of Editor but useEditor still returns
null
.What browser are you using?
Chrome
Code example
No response
What did you expect to happen?
Expected my unit tests not to fail as in previous version.
Anything to add? (optional)
No response
Did you update your dependencies?
Are you sponsoring us?
The text was updated successfully, but these errors were encountered: