Is it possible to reliably get the full context of codemirror editor in tests?

In one of the tests I’d like to check for the content of the editor (editor is part of a bigger page in our case and we need to validate that value is preserved for different scenarious).

I tried multiple things:

cy.findByRole('textbox').invoke('text').then((text) => {})
cy.get('.cm-line').then($lines => {
  const fullText = [...$lines].map(l => l.textContent).join('\n');
});

In any case the text is not complete (due to virtualization, I believe).

Is there any way to reliably get the text content of codemirror editor?

There is a very hacky way like

useEffect(() => {
  if (view) {
    window.editorView = view;
  }
}, [view]);

but I wouldn’t like to do this.

Alternatively what worked is to go line by line and check each line content.

cy.get('.cm-line').contains('...').should('exist')

This is what I used so far but it reduces readability imho.

Maybe EditorView.findFromDOM is what you are looking for?