Generate EditorState from a string

I am trying to test a function I wrote that traverses the syntaxTree.

Previously, I had a global React hook that would receive the EditorView from a mounted CodeMirror instance. I could simulate user typing via React Testing Library and process the EditorState function I wrote. I’ve had to refactor this code to be simpler, with more explicit state setting. This means I’ve lost my global hook and don’t have a good way to test rendering CodeMirror and pulling out the EditorView.

Is there a way to generate an EditorView/EditorState from a string? Once I have the generated state, I can pass that to my function to process it. This is what it’s doing now, but the tricky part is generating the state from CodeMirror to give to my function. I had simply rendered CodeMirror and simulated typing to get this. I wasn’t sure how to do it as I’m describing now, programmatically (or renderlessly?).

I found the function that does this. It was right in front of my face!

Found through How to set new doc content - #2 by fkling

EditorState.create({
  doc: 'my new content', 
  extensions: [sql({upperCaseKeywords: true})]
})