Ionaru / easy-markdown-editor

EasyMDE: A simple, beautiful, and embeddable JavaScript Markdown editor. Delightful editing for beginners and experts alike. Features built-in autosaving and spell checking.
https://stackblitz.com/edit/easymde
MIT License
2.31k stars 308 forks source link

Any guides for testing with this thing? #557

Open dwjohnston opened 10 months ago

dwjohnston commented 10 months ago

I'm wanting to write some tests against our our customised version of this tool. I'm having trouble with both Testing Library and Cypress.

With testing library - I can do this:

    userEvent.type(screen.getByRole("textbox"), "some plain text");

But I can't test keyboard short cuts like:

    userEvent.type(screen.getByRole("textbox"), "hello{meta}b{meta/}world")

With cypress I'm finding that I can enter text like:

 cy.get('.CodeMirror').type(
      "aaa"
    );

Also:

    cy.get('.CodeMirror').type(
      "hello{meta+b}world"
    );

Any other guides/best practises for testing?

Ionaru commented 9 months ago

The tests in this repo may be a good example: https://github.com/Ionaru/easy-markdown-editor/tree/master/cypress/e2e

As far as testing keyboard shortcuts I have not tried that.

dwjohnston commented 8 months ago

@Ionaru

I've written a guide for testing here: https://blacksheepcode.com/posts/testing_easy_mde

The main take away is: