Comments (4)
Try to use mount
if you use an enzyme
for testing.
This module heavily relies on Web API and DOM elements itself, since it's just a wrapper around simplemde
editor which is not using any library such as React
but pure JS to control stuff.
So it may be a tricky thing to make it run in a the unit test environment.
You can test it easily using cypress
which is an amazing tool for e2e
testing IN the browser itself.
If anyone can give more insights, will be glad.
from react-simplemde-editor.
I forgot to mention that you would need to have jsdom
for it to be tested I think.
from react-simplemde-editor.
I'm having this issue as well. And I think I can elaborate a little bit.
I have a wrapper component for the editor. Testing this wrapper component with enzyme seems to work just fine.
But then I use this wrapper component inside of other components. Testing those with enzyme causes the same errors above.
Edit: After messing around a bit, it looks like it might be possible to get around this issue by using react ref's for editorEl and grabbing editorToolbar through that ref. Also, adding a null check in componentWillUnmount()
addEvents = () => { this.editorEl = this.elementWrapperRef; this.editorToolbarEl = this.elementWrapperRef.getElementsByClassName("editor-toolbar")[0]; ...
componentWillUnmount() { if (!isNullOrUndefined(this.editorEl)) { this.removeEvents(); } }
from react-simplemde-editor.
I'll deploy in a minute a new version with the fix of @etlas hope it will help.
from react-simplemde-editor.
Related Issues (20)
- Custom toolbar button to open a separate React component (or any kind of div input from where I can accept input) HOT 3
- How can I disable markdown AutoComplete feature? HOT 1
- lost focus when using onChange with nextjs HOT 7
- lineNumbers option prevents backspace of empty line on Mobile HOT 2
- TypeError `_react.useMemo` is not a function HOT 3
- how to make this RTL ? HOT 7
- Cursor randomly jumps before first character when typing HOT 1
- can't use options when use getCodemirrorInstance to change state HOT 1
- window is not defined HOT 3
- Preview not working (showing undefined) HOT 5
- You may need an additional loader to handle the result of these loaders. HOT 4
- toolbar does not display on MacOS HOT 2
- Enforce maxLength attribute HOT 3
- Editor fetches assets from external sources HOT 1
- Multiline Code Block Highlighting in Edit Mode HOT 1
- Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()? HOT 2
- has fetching error with react query HOT 3
- How to add thin blue border upon selecting the editor?
- Tailwind Reset HOT 1
- Using in Next.js client component caused a ReferenceError on the server when the page loads HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-simplemde-editor.