How to fake input to code mirror from view?

I try to write tests for editor, and for the sake of tests I’d like to fake input into the editor.

For tests of state, I managed to fake it by calling:

return ({state, dispatch}) => dispatch({userEvent: 'input.type', ...state.replaceSelection(letter)});

but how can I fake input for view?

  1. should i just replace .innerHtml of .cm-content and then manually call "input" event?
  2. should I just change particular .cm-line?
  3. try to approach it from MutationObserver way?

I’m happy to write code that can “simulate” a browser, but my question is - what behaviour exactly does code mirror rely on input?

It mostly just observes DOM changes, so updating the DOM should cover it, mostly. Except for composition input, there you’d want to fire compositionstart/update/end events as well.

Okay, thanks!

And how would I fake changes of focus or selection?