DEV Community

Cover image for Answer: How can I clear a Codemirror editor field from Cypress
Jacob Evans
Jacob Evans

Posted on • Updated on

Answer: How can I clear a Codemirror editor field from Cypress

I was able to with a little help from another answer in the responses to come up with a solution.

  1. Problem domain involved embedded editor CodeMirror
  2. I wanted to use Cypress to remove all Text in a field then simulate a user typing in all their own, like a copy-paste.
  3. Could not remove code from the editor with Cypress as expected.

Normally I am afraid to use StackOverflow because I don't want to be shutdown or talked down too. I tweeted my question and got a great response; friendly and helpful! This is the type of interaction I love to see in StackOverflow.
Big thanks again to @evanplaice for seeing my tweet and helping out, here is his Twitter: https://twitter.com/evanplaice

The solution I ended up using looked something similar to code block in the question with a few changes.

  • I am not getting the window object from Cypress; CodeMirror editor wasn't there.

  • I used the idea Evan Plaice gave me related to the Editor instance being on the DOM and…

Top comments (0)