Coder Social home page Coder Social logo

Unit testing/coverage about react-codemirror2 HOT 4 CLOSED

scniro avatar scniro commented on September 15, 2024
Unit testing/coverage

from react-codemirror2.

Comments (4)

PatrM avatar PatrM commented on September 15, 2024 6

I just gonna add my Issue here, since I seem to be struggling with something similar.

TypeError: document.body.createTextRange is not a function

      at range (node_modules/codemirror/lib/codemirror.js:94:25)
      at hasBadBidiRects (node_modules/codemirror/lib/codemirror.js:1244:12)
      at buildLineContent (node_modules/codemirror/lib/codemirror.js:1825:9)
      at updateExternalMeasurement (node_modules/codemirror/lib/codemirror.js:2429:28)
      at prepareMeasureForLine (node_modules/codemirror/lib/codemirror.js:2465:14)
      at measureChar (node_modules/codemirror/lib/codemirror.js:2438:34)
      at endOperation_R2 (node_modules/codemirror/lib/codemirror.js:3788:24)
      at endOperations (node_modules/codemirror/lib/codemirror.js:3754:7)
      at node_modules/codemirror/lib/codemirror.js:3741:5
      at finishOperation (node_modules/codemirror/lib/codemirror.js:2119:5)
      at endOperation (node_modules/codemirror/lib/codemirror.js:3738:3)
      at new CodeMirror$1 (node_modules/codemirror/lib/codemirror.js:7824:3)
      at CodeMirror$1 (node_modules/codemirror/lib/codemirror.js:7765:49)
      at Controlled.Object.<anonymous>.Controlled.componentDidMount (node_modules/react-codemirror2/index.js:264:23)

I'm just running the basic renders without crashing test, starting & using the app works just fine.

@scniro did you have any success solving this issue?

I'll let you guys know if i find something in the meantime!

EDIT:
Turned out it was an issue with JSDOM and not codemirror, my bad.
I found a solution for my issue here

from react-codemirror2.

KevinGrandon avatar KevinGrandon commented on September 15, 2024

Just stopping by and not sure if you've figured out your problems or not. I noticed that you were using Enzyme.shallow which does not run the react component lifecycle. I think you'll need to perform a full mount in case you need to run lifecycle methods.

from react-codemirror2.

scniro avatar scniro commented on September 15, 2024

@KevinGrandon Hey thanks for checking in on this. I've been working on a 4.x release for a bit that'll be coming up soon and I've managed to get around ~85% coverage which is definitely heading in the right direction. I have been using .mount where it makes sense, but there is still the struggle of dealing with then-later-rendered DOM escaping the enzyme API. I've found a few creative ways to get around it, but it's still less than ideal. I'll chalk it up as a just-deal-with-it because testing a third-party component that's simply shipped in a react component wrapper is not an ideal situation anyways. Thank you for your interest on this!

from react-codemirror2.

scniro avatar scniro commented on September 15, 2024

@PatrM @KevinGrandon I am a lot shorter on time these days as when I started this project. Codemirror & React APIs are moving to quickly for me to keep atop of for the day-to-day. I am looking for a co-maintainer of this project. Please contact me directly if you are interested. Thank you for understanding.

from react-codemirror2.

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.