diff --git a/cli/types/index.d.ts b/cli/types/index.d.ts index 97dfec2831d0..ccac0a46b5bc 100644 --- a/cli/types/index.d.ts +++ b/cli/types/index.d.ts @@ -750,7 +750,7 @@ declare namespace Cypress { * cy.get('input').should('be.disabled') * cy.get('button').should('be.visible') */ - get(selector: K, options?: Partial): Chainable> + get(selector: K, options?: Partial): Chainable> /** * Get one or more DOM elements by selector. * The querying behavior of this command matches exactly how $(…) works in jQuery. @@ -760,7 +760,7 @@ declare namespace Cypress { * cy.get('ul li:first').should('have.class', 'active') * cy.get('.dropdown-menu').click() */ - get(selector: string, options?: Partial): Chainable> + get(selector: string, options?: Partial): Chainable> /** * Get one or more DOM elements by alias. * @see https://on.cypress.io/get#Alias @@ -771,7 +771,7 @@ declare namespace Cypress { * //later retrieve the todos * cy.get('@todos') */ - get(alias: string, options?: Partial): Chainable + get(alias: string, options?: Partial): Chainable /** * Get a browser cookie by its name. @@ -1838,6 +1838,20 @@ declare namespace Cypress { retryOnNetworkFailure: boolean } + /** + * Options that control how a command behaves in the `within` scope. + * These options will determine how nodes are selected. + */ + + interface Withinable { + /** + * Element to search for children in. If null, search begins from root-level DOM element. + * + * @default depends on context, null if outside of within wrapper + */ + withinSubject: JQuery | HTMLElement | null + } + /** * Options that control how a command is logged in the Reporter */ diff --git a/cli/types/tests/cypress-tests.ts b/cli/types/tests/cypress-tests.ts index 14b242f6213b..8e5fc46bb64d 100644 --- a/cli/types/tests/cypress-tests.ts +++ b/cli/types/tests/cypress-tests.ts @@ -219,6 +219,12 @@ cy.get('body').within({ log: false }, body => { body // $ExpectType JQuery }) +cy.get('body').within(() => { + cy.get('body', { withinSubject: null }).then(body => { + body // $ExpectType JQuery + }) +}) + cy .get('body') .then(() => {