Socket
Socket
Sign inDemoInstall

cypress-ct-custom-elements

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cypress-ct-custom-elements

Framework definition for testing custom elements (web components) in Cypress component testing


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Install size
15.2 kB
Created
Weekly downloads
 

Readme

Source

A Cypress Framework Definition for testing your custom elements (web components). It simply puts your custom element into the HTML. No other actions are triggered.

To use this framework, first install it.

npm install cypress-ct-custom-elements

Next, modify your cypress.config.ts (or your own config if not using TypeScript) and set the framework.

import { defineConfig } from 'cypress';

export default defineConfig({
    component: {
        devServer: {
            bundler: 'vite',
            framework: 'cypress-ct-custom-elements',
            includeShadowDom: true
        }
    }
});

Finally, add a test file, such as cypress/component/basic.cy.ts.

import { YourComponent } from '../../src';

customElements.define('your-component', YourComponent);

describe('basic initialization', () => {
    beforeEach(() => {
        cy.mount('<your-component></your-component>');
    });

    it('passes a test that you have to make', () => {
        cy.get('your-component').should('.......');
    });
});

See the documentation to Learn how to author a Framework Definition for your favorite library!

Keywords

FAQs

Last updated on 23 Nov 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc