Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cypress-controls-ext

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypress-controls-ext

Extension to embed controls to controls panel in cypress app

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

    // 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
     };
    
  3. 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

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

Todo

  • predefined controls (checkbox, dropdown)

Keywords

FAQs

Package last updated on 18 Apr 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc