Giter VIP home page Giter VIP logo

Comments (4)

RIP21 avatar RIP21 commented on June 10, 2024

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.

RIP21 avatar RIP21 commented on June 10, 2024

I forgot to mention that you would need to have jsdom for it to be tested I think.

from react-simplemde-editor.

pridgey avatar pridgey commented on June 10, 2024

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.

RIP21 avatar RIP21 commented on June 10, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.