New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@dbcdk/cypress-commands

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dbcdk/cypress-commands

A collection of handy cypress commands

latest
Source
npmnpm
Version
1.1.3
Version published
Maintainers
1
Created
Source

Cypress commands

For faster and easier testing


How to use

Include this function call in the e2e/cypress/support/commands.js

import CypressCommands from 'cypress-commands';

CypressCommands();

Commands


isInViewport

Checks if element is in the viewport's boundaries

Cypress.Commands.add("isInViewport", element => {
    cy.get(element).then($el => {
        const bottom = Cypress.$(cy.state("window")).height();
        const rect = $el[0].getBoundingClientRect();

        expect(rect.top).not.to.be.greaterThan(bottom);
        expect(rect.bottom).not.to.be.greaterThan(bottom);
        expect(rect.top).not.to.be.greaterThan(bottom);
        expect(rect.bottom).not.to.be.greaterThan(bottom);
    });
});

Example of use

cy.isInViewport("[data-cy=element-name]");

isNotInViewport

Cypress.Commands.add("isNotInViewport", element => {
    cy.get(element).then($el => {
        const bottom = Cypress.$(cy.state("window")).height();
        const rect = $el[0].getBoundingClientRect();

        expect(rect.top).to.be.greaterThan(bottom);
        expect(rect.bottom).to.be.greaterThan(bottom);
        expect(rect.top).to.be.greaterThan(bottom);
        expect(rect.bottom).to.be.greaterThan(bottom);
    });
});

Example of use

cy.isNotInViewport("[data-cy=element-name]");

FAQs

Package last updated on 24 Mar 2025

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