0.2.0 • Published 1 year ago

cypress-controls-ext v0.2.0

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

cypress-controls-ext

Extension to embed controls to controls panel in cypress app

Can have event listeners and custom style

alt preview

Setup

Prerequisites:

  • cypress installed in project

Steps: 1. install package

```
npm i --save-dev cypress-controls-ext
```
or

```

yarn add -D cypress-controls-ext

2. create control - object of type SetupControlSettings
 
```typescript
// simple example, you can put that into separate file
export const myControl: SetupControlSettings = {
   // uniq id to html element
   id: 'my-button',

   // in what modes to inject control
   mode: {
     run: false,
     open: true,
   },

   // html for your control
   control: () => `<button id="myBut">Button</button>`,

   // event listener for control
   // add correct selector (with parentId)
   addEventListener: (parentId: string, listener: ListenerSetting) => {
     listener('#' + parentId + ' #myBut', 'click', () => {
       // will log message on #myBut click
       Cypress.log({ name: 'CLICK', message: '#myBut' });
     });
   },
   // also optional style handler could be added here
 };
  1. register control before tests

    You can do that

    • by setupControlsExtensionWithEvent(myControl); in support/index.js file : constrol will be Cypress.on('test:before:run:async'...
    • by setupControlsExtension(myControl) - this doesn't use event

Features

  • You can add several controls
  • You can add style handler

      ...
        mode: { run: true, open: true },
        id: 'myButton',
        style: (parentId: string) => &grave;
          #${parentId} {
            background-color: '#569532'};
          }
    
          #${parentId} .turn-mock-on-label {
            padding: 5px;
            color: red;
            font-weight: bold;
          }
        &grave;,
    ...

Examples

Todo

  • predefined controls (checkbox, dropdown)
0.1.2

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.7

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.0

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago