@commercetools-frontend/cypress
Version:
Cypress commands and utilities for Custom Applications
42 lines (41 loc) • 1.82 kB
TypeScript
/**
* NOTE: the `realHover` command is originally being implemented in `cypress-real-events` package.
* https://github.com/dmtrKovalenko/cypress-real-events/blob/develop/src/commands/realHover.ts
*
* However, due to known issues with conflicting types between Cypress and Jest, importing the `cypress-real-events`
* package here will cause such issues with TypeScript as our `@commercetools-frontend/cypress` package
* is checked and built together with all other packages and not in isolation.
* See https://docs.cypress.io/guides/tooling/typescript-support#Clashing-types-with-Jest.
*
* Therefore, we are porting here the implementation of `realHover` to avoid importing it from the
* original package `cypress-real-events`.
*/
export interface RealHoverOptions {
/**
* If set to `pen`, simulates touch based hover (via long press)
*/
pointer?: 'mouse' | 'pen';
/**
* Position relative to the element where to hover the element.
* @example cy.realHover({ position: "topLeft" })
*/
position?: Position;
/**
* Controls how the page is scrolled to bring the subject into view, if needed.
* @example cy.realHover({ scrollBehavior: "top" });
*/
scrollBehavior?: ScrollBehaviorOptions;
/**
* Indicates whether the shift key was pressed or not when an event occurred
* @example cy.realHover({ shiftKey: true });
*/
shiftKey?: boolean;
}
type Position = 'topLeft' | 'top' | 'topRight' | 'left' | 'center' | 'right' | 'bottomLeft' | 'bottom' | 'bottomRight' | {
x: number;
y: number;
};
type ScrollBehaviorPosition = 'center' | 'top' | 'bottom' | 'nearest';
type ScrollBehaviorOptions = ScrollBehaviorPosition | false;
export declare function realHover(subject: any, options?: RealHoverOptions): Promise<any>;
export {};