Socket
Book a DemoInstallSign in
Socket

cypress-cotrols-extension

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

cypress-cotrols-extension

Extension to embed controls to controls panel in cypress app

unpublished
latest
Source
npmnpm
Version
0.0.11
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

cypress-controls-extension

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:

  • install package

    npm i --save-dev cypress-controls-extension
    

    or

    yarn add -D cypress-controls-extension
    
  • create control - object of type SetupControlSettings

    // simple example, you can put that into separate file
    export const myControl = {
       // 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
       addEventListener: (parentId: string, listener: ListenerSetting) => {
         listener('#myBut', 'click', () => {
           // will log message on #myBut click
           Cypress.log({ name: 'CLICK', message: '#myBut' });
         });
       },
       // also optional style handler could be added here
     };
    
  • 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) => &grave;
          #${parentId} {
            background-color: ${getStoredVar('MOCK') ? '#569532' : 'rgb(160,44,145)'};
          }
    
          #turnMockOnLabel {
            padding:5px;
            color: ${getStoredVar('MOCK') ? '#fff' : '#fff'};
            font-weight: bold;
          }&grave;,
    ...
    

Examples

  • Check out mock-button control
  • Cypress test for using mock-button: demo.cy.ts

Todo

  • predefined controls (checkbox, dropdown)

Keywords

cypress

FAQs

Package last updated on 22 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts