mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-26 17:09:11 -06:00
Publicly export withinSubject option on get command (#2791)
* Publicly export withinSubject field on get requests * Fix linting * review adjustments
This commit is contained in:
committed by
Zach Bloomquist
parent
13b5a0acda
commit
27ccf751ba
20
cli/types/index.d.ts
vendored
20
cli/types/index.d.ts
vendored
@@ -750,7 +750,7 @@ declare namespace Cypress {
|
||||
* cy.get('input').should('be.disabled')
|
||||
* cy.get('button').should('be.visible')
|
||||
*/
|
||||
get<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
|
||||
get<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable & Withinable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
|
||||
/**
|
||||
* 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<E extends Node = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
|
||||
get<E extends Node = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable & Withinable>): Chainable<JQuery<E>>
|
||||
/**
|
||||
* 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<S = any>(alias: string, options?: Partial<Loggable & Timeoutable>): Chainable<S>
|
||||
get<S = any>(alias: string, options?: Partial<Loggable & Timeoutable & Withinable>): Chainable<S>
|
||||
|
||||
/**
|
||||
* Get a browser cookie by its name.
|
||||
@@ -1855,6 +1855,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
|
||||
*/
|
||||
|
||||
@@ -219,6 +219,12 @@ cy.get('body').within({ log: false }, body => {
|
||||
body // $ExpectType JQuery<HTMLBodyElement>
|
||||
})
|
||||
|
||||
cy.get('body').within(() => {
|
||||
cy.get('body', { withinSubject: null }).then(body => {
|
||||
body // $ExpectType JQuery<HTMLBodyElement>
|
||||
})
|
||||
})
|
||||
|
||||
cy
|
||||
.get('body')
|
||||
.then(() => {
|
||||
|
||||
Reference in New Issue
Block a user