UNPKG

@helpscout/cyan

Version:

Cypress-like Testing for React + JSDOM

143 lines (142 loc) 3.46 kB
/** * Get the children DOM elements from the main DOM element. * * @returns {Cyan} The Cyan instance. * * @example * cy.get('ul').children() */ declare function children(): any; /** * Get the first closest DOM element with a matching selector from the main DOM element. * * @param {string} selector A selector used to find a matching DOM element. * @returns {Cyan} The Cyan instance. * * @example * cy.get('div').closest('main') */ declare function closest(selector: any): any; /** * Iterate through the main DOM elements. * * @param {Function<Element>} callback A callback invoked with the iterating DOM elements. * @returns {Cyan} The Cyan instance. * * @example * cy.get('div').each((node, index) => { * node.classList.add(`item-${index}`) * }) */ declare function each(callback: any): any; /** * Get a DOM element based on it's index number. * * @param {number} index A number indicating the index of the element to get. * @returns {Cyan} The Cyan instance. * * @example * cy.get('ul > li').eq(2) */ declare function eq(index: any): any; /** * Get the DOM elements that match a specific selector. * * @param {string} selector A selector used for filter matching. * @returns {Cyan} The Cyan instance. * * @example * cy.get('ul > li').filter('.item') */ declare function filter(selector: any): any; /** * Get descendent DOM elements that match a specific selector. * * @param {string} selector A selector used for descendent matching. * @returns {Cyan} The Cyan instance. * * @example * cy.get('ul').findByCy('Item') */ declare function findByCy(selector: any): any; /** * Get descendent DOM elements that match a specific data-cy selector. * * @param {string} selector A selector used for descendent matching. * @returns {Cyan} The Cyan instance. * * @example * cy.get('ul').find('li.item') */ declare function find(selector: any): any; /** * Get the first DOM element from the main DOM elements. * * @returns {Cyan} The Cyan instance. * * @example * cy.get('ul > li').first() */ declare function first(): any; /** * Get the last DOM element from the main DOM elements. * * @returns {Cyan} The Cyan instance. * * @example * cy.get('ul > li').last() */ declare function last(): any; /** * Get the next sibling DOM element from the main DOM element. * * @returns {Cyan} The Cyan instance. * * @example * cy.get('ul > li').eq(3).next() */ declare function next(): any; /** * Filter DOM elements from the main DOM elements. * * @param {string} selector A selector used for filter matching. * @returns {Cyan} The Cyan instance. * * @example * cy.get('ul > li').not('.item') */ declare function not(selector: any): any; /** * Get the parent DOM element from the main DOM element. * * @returns {Cyan} The Cyan instance. * * @example * cy.get('li').parent() */ declare function parent(): any; /** * Get the previous sibling DOM element from the main DOM element. * * @returns {Cyan} The Cyan instance. * * @example * cy.get('ul > li').eq(3).prev() */ declare function prev(): any; declare const commands: { children: typeof children; closest: typeof closest; each: typeof each; eq: typeof eq; filter: typeof filter; find: typeof find; findByCy: typeof findByCy; first: typeof first; last: typeof last; next: typeof next; not: typeof not; parent: typeof parent; prev: typeof prev; }; export default commands;