1.0.0-alpha • Published 4 years ago

@editorjs/cypress-commands v1.0.0-alpha

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

npm.io

@editorjs/cypress-commands

Set of Cypress commands for Editor.js testing purposes

Installation

Install the package using yarn or npm

yarn add -D @editorjs/cypress-commands

npm install --save-dev @editorjs/cypress-commands

Add import to cypress/support/index file:

import '@editorjs/cypress-commands'

List of commands

NameDescription
initEditorJSLoads fixture html page with initalized EditorJS
getEditorYelds EditorJS HTMLElement container
getBlockYelds EditorJS block HTMLElement
openBlockSettingsOpens settings popover for Block and yelds it's HTMLElement

Access to EditorJS instance

You can access EditorJS object with API methods via EditorJS alias:

cy.get<EditorJS>('@EditorJS')
  .then(async editor => {
    await editor.save();
  });

Loading your tool

Fixture HTML page contains loadScript method to allow you to load your Tool on the page.

Also package provide a task to resolve path to package

before(() => {
  cy.task('resolvePathToPackage', 'my-tool-package-name', (pathToPackage) => {
    cy.window()
      .then(async win => {
        await win.loadScript(pathToPackage, 'script-id');

        cy.initEditorJS({
          tools: {
            myTool: win.MyTool
          }
        });
      });  
  });
});