@revoloo/cypress6
Version:
Cypress.io end to end testing tool
1,363 lines (1,270 loc) • 224 kB
TypeScript
/// <reference path="./cypress-npm-api.d.ts" />
/// <reference path="./cypress-eventemitter.d.ts" />
declare namespace Cypress {
type FileContents = string | any[] | object
type HistoryDirection = 'back' | 'forward'
type HttpMethod = string
type RequestBody = string | object
type ViewportOrientation = 'portrait' | 'landscape'
type PrevSubject = 'optional' | 'element' | 'document' | 'window'
type PluginConfig = (on: PluginEvents, config: PluginConfigOptions) => void | ConfigOptions | Promise<ConfigOptions>
interface CommandOptions {
prevSubject: boolean | PrevSubject | PrevSubject[]
}
interface ObjectLike {
[key: string]: any
}
interface Auth {
username: string
password: string
}
interface Backend {
/**
* Firefox only: Force Cypress to run garbage collection routines.
* No-op if not running in Firefox.
*
* @see https://on.cypress.io/firefox-gc-issue
*/
(task: 'firefox:force:gc'): Promise<void>
(task: 'net', eventName: string, frame: any): Promise<void>
}
type BrowserName = 'electron' | 'chrome' | 'chromium' | 'firefox' | 'edge' | string
type BrowserChannel = 'stable' | 'canary' | 'beta' | 'dev' | 'nightly' | string
type BrowserFamily = 'chromium' | 'firefox'
/**
* Describes a browser Cypress can control
*/
interface Browser {
/**
* Short browser name.
*/
name: BrowserName
/**
* The underlying engine for this browser.
*/
family: BrowserFamily
/**
* The release channel of the browser.
*/
channel: BrowserChannel
/**
* Human-readable browser name.
*/
displayName: string
version: string
majorVersion: number
path: string
isHeaded: boolean
isHeadless: boolean
}
interface LocalStorage {
/**
* Called internally to clear `localStorage` in two situations.
*
* 1. Before every test, this is called with no argument to clear all keys.
* 2. On `cy.clearLocalStorage(keys)` this is called with `keys` as an argument.
*
* You should not call this method directly to clear `localStorage`; instead, use `cy.clearLocalStorage(key)`.
*
* @see https://on.cypress.io/clearlocalstorage
*/
clear: (keys?: string[]) => void
}
type IsBrowserMatcher = BrowserName | Partial<Browser> | Array<BrowserName | Partial<Browser>>
interface ViewportPosition extends WindowPosition {
right: number
bottom: number
}
interface WindowPosition {
top: number
left: number
topCenter: number
leftCenter: number
}
interface ElementPositioning {
scrollTop: number
scrollLeft: number
width: number
height: number
fromElViewport: ViewportPosition
fromElWindow: WindowPosition
fromAutWindow: WindowPosition
}
interface ElementCoordinates {
width: number
height: number
fromElViewport: ViewportPosition & { x: number, y: number }
fromElWindow: WindowPosition & { x: number, y: number }
fromAutWindow: WindowPosition & { x: number, y: number }
}
/**
* Spec type for the given test. "integration" is the default, but
* tests run using experimentalComponentTesting will be "component"
*
* @see https://on.cypress.io/experiments
*/
type CypressSpecType = 'integration' | 'component'
/**
* A Cypress spec.
*/
interface Spec {
name: string // "config_passing_spec.js"
relative: string // "cypress/integration/config_passing_spec.js" or "__all" if clicked all specs button
absolute: string // "/Users/janelane/app/cypress/integration/config_passing_spec.js"
specFilter?: string // optional spec filter used by the user
specType?: CypressSpecType
}
/**
* Window type for Application Under Test(AUT)
*/
type AUTWindow = Window & typeof globalThis & ApplicationWindow
/**
* The interface for user-defined properties in Window object under test.
*/
interface ApplicationWindow {} // tslint:disable-line
/**
* Several libraries are bundled with Cypress by default.
*
* @see https://on.cypress.io/api
*/
interface Cypress {
/**
* Lodash library
*
* @see https://on.cypress.io/_
* @example
* Cypress._.keys(obj)
*/
_: _.LoDashStatic
/**
* jQuery library
*
* @see https://on.cypress.io/$
* @example
* Cypress.$('p')
*/
$: JQueryStatic
/**
* Cypress automatically includes a Blob library and exposes it as Cypress.Blob.
*
* @see https://on.cypress.io/blob
* @see https://github.com/nolanlawson/blob-util
* @example
* Cypress.Blob.method()
*/
Blob: BlobUtil.BlobUtilStatic
/**
* Cypress automatically includes minimatch and exposes it as Cypress.minimatch.
*
* @see https://on.cypress.io/minimatch
*/
minimatch: typeof Minimatch.minimatch
/**
* @deprecated Will be removed in a future version.
* Consider including your own datetime formatter in your tests.
*
* Cypress automatically includes moment.js and exposes it as Cypress.moment.
*
* @see https://on.cypress.io/moment
* @see http://momentjs.com/
* @example
* const todaysDate = Cypress.moment().format("MMM DD, YYYY")
*/
moment: Moment.MomentStatic
/**
* Cypress automatically includes Bluebird and exposes it as Cypress.Promise.
*
* @see https://on.cypress.io/promise
* @see https://github.com/petkaantonov/bluebird
* @example
* new Cypress.Promise((resolve, reject) => { ... })
*/
Promise: Bluebird.BluebirdStatic
/**
* Cypress includes Sinon.js library used in `cy.spy` and `cy.stub`.
*
* @see https://sinonjs.org/
* @see https://on.cypress.io/stubs-spies-and-clocks
* @see https://example.cypress.io/commands/spies-stubs-clocks
*/
sinon: sinon.SinonStatic
/**
* Cypress version string. i.e. "1.1.2"
* @see https://on.cypress.io/version
* @example
```
expect(Cypress.version).to.be.a('string')
if (Cypress.version === '1.2.0') {
// test something specific
}
```
*/
version: string
/**
* OS platform name, from Node `os.platform()`
*
* @see https://nodejs.org/api/os.html#os_os_platform
* @example
* Cypress.platform // "darwin"
*/
platform: string
/**
* CPU architecture, from Node `os.arch()`
*
* @see https://nodejs.org/api/os.html#os_os_arch
* @example
* Cypress.arch // "x64"
*/
arch: string
/**
* Currently executing spec file.
* @example
* ```
* Cypress.spec
* // {
* // name: "config_passing_spec.coffee",
* // relative: "cypress/integration/config_passing_spec.coffee",
* // absolute: "/users/smith/projects/web/cypress/integration/config_passing_spec.coffee"
* // specType: "integration"
* // }
* ```
*/
spec: Spec
/**
* Information about the browser currently running the tests
*/
browser: Browser
/**
* Internal class for LocalStorage management.
*/
LocalStorage: LocalStorage
/**
* Fire automation:request event for internal use.
*/
automation(eventName: string, ...args: any[]): Promise<any>
/**
* Promise wrapper for certain internal tasks.
*/
backend: Backend
/**
* Returns all configuration objects.
* @see https://on.cypress.io/config
* @example
```
Cypress.config()
// {defaultCommandTimeout: 10000, pageLoadTimeout: 30000, ...}
```
*/
config(): ResolvedConfigOptions & RuntimeConfigOptions
/**
* Returns one configuration value.
* @see https://on.cypress.io/config
* @example
```
Cypress.config('pageLoadTimeout')
// 60000
```
*/
config<K extends keyof ConfigOptions>(key: K): ResolvedConfigOptions[K]
/**
* Sets one configuration value.
* @see https://on.cypress.io/config
* @example
```
Cypress.config('viewportWidth', 800)
```
*/
config<K extends keyof ConfigOptions>(key: K, value: ResolvedConfigOptions[K]): void
/**
* Sets multiple configuration values at once.
* @see https://on.cypress.io/config
* @example
```
Cypress.config({
defaultCommandTimeout: 10000,
viewportHeight: 900
})
```
*/
config(Object: ConfigOptions): void
// no real way to type without generics
/**
* Returns all environment variables set with CYPRESS_ prefix or in "env" object in "cypress.json"
*
* @see https://on.cypress.io/env
*/
env(): ObjectLike
/**
* Returns specific environment variable or undefined
* @see https://on.cypress.io/env
* @example
* // cypress.json
* { "env": { "foo": "bar" } }
* Cypress.env("foo") // => bar
*/
env(key: string): any
/**
* Set value for a variable.
* Any value you change will be permanently changed for the remainder of your tests.
* @see https://on.cypress.io/env
* @example
* Cypress.env("host", "http://server.dev.local")
*/
env(key: string, value: any): void
/**
* Set values for multiple variables at once. Values are merged with existing values.
* @see https://on.cypress.io/env
* @example
* Cypress.env({ host: "http://server.dev.local", foo: "foo" })
*/
env(object: ObjectLike): void
/**
* Firefox only: Get the current number of tests that will run between forced garbage collections.
*
* Returns undefined if not in Firefox, returns a null or 0 if forced GC is disabled.
*
* @see https://on.cypress.io/firefox-gc-issue
*/
getFirefoxGcInterval(): number | null | undefined
/**
* @returns the number of test retries currently enabled for the run
*/
getTestRetries(): number | null
/**
* Checks if a variable is a valid instance of `cy` or a `cy` chainable.
*
* @see https://on.cypress.io/iscy
* @example
* Cypress.isCy(cy) // => true
*/
isCy<TSubject = any>(obj: Chainable<TSubject>): obj is Chainable<TSubject>
isCy(obj: any): obj is Chainable
/**
* Returns true if currently running the supplied browser name or matcher object. Also accepts an array of matchers.
* @example isBrowser('chrome') will be true for the browser 'chrome:canary' and 'chrome:stable'
* @example isBrowser({ name: 'firefox', channel: 'dev' }) will be true only for the browser 'firefox:dev' (Firefox Developer Edition)
* @example isBrowser(['firefox', 'edge']) will be true only for the browsers 'firefox' and 'edge'
* @example isBrowser('!firefox') will be true for every browser other than 'firefox'
* @example isBrowser({ family: '!chromium'}) will be true for every browser not matching { family: 'chromium' }
* @param matcher browser name or matcher object to check.
*/
isBrowser(name: IsBrowserMatcher): boolean
/**
* Internal options for "cy.log" used in custom commands.
*
* @see https://on.cypress.io/cypress-log
*/
log(options: Partial<LogConfig>): Log
/**
* @see https://on.cypress.io/api/commands
*/
Commands: {
add(name: string, fn: (...args: any[]) => CanReturnChainable): void
add(name: string, options: CommandOptions, fn: (...args: any[]) => CanReturnChainable): void
overwrite(name: string, fn: (...args: any[]) => CanReturnChainable): void
}
/**
* @see https://on.cypress.io/cookies
*/
Cookies: {
debug(enabled: boolean, options?: Partial<DebugOptions>): void
preserveOnce(...names: string[]): void
defaults(options: Partial<CookieDefaults>): void
}
/**
* @see https://on.cypress.io/dom
*/
dom: {
/**
* Returns a jQuery object obtained by wrapping an object in jQuery.
*/
wrap(wrappingElement_function: JQuery.Selector | JQuery.htmlString | Element | JQuery | ((index: number) => string | JQuery)): JQuery
query(selector: JQuery.Selector, context?: Element | JQuery): JQuery
/**
* Returns an array of raw elements pulled out from a jQuery object.
*/
unwrap(obj: any): any
/**
* Returns a boolean indicating whether an object is a DOM object.
*/
isDom(obj: any): boolean
isType(element: JQuery | HTMLElement, type: string): boolean
/**
* Returns a boolean indicating whether an element is visible.
*/
isVisible(element: JQuery | HTMLElement): boolean
/**
* Returns a boolean indicating whether an element is hidden.
*/
isHidden(element: JQuery | HTMLElement, methodName?: string, options?: object): boolean
/**
* Returns a boolean indicating whether an element can receive focus.
*/
isFocusable(element: JQuery | HTMLElement): boolean
isTextLike(element: JQuery | HTMLElement): boolean
/**
* Returns a boolean indicating whether an element is scrollable.
*/
isScrollable(element: Window | JQuery | HTMLElement): boolean
/**
* Returns a boolean indicating whether an element currently has focus.
*/
isFocused(element: JQuery | HTMLElement): boolean
/**
* Returns a boolean indicating whether an element is detached from the DOM.
*/
isDetached(element: JQuery | HTMLElement): boolean
/**
* Returns a boolean indicating whether an element is attached to the DOM.
*/
isAttached(element: JQuery | HTMLElement | Window | Document): boolean
isSelector(element: JQuery | HTMLElement, selector: JQuery.Selector): boolean
/**
* Returns a boolean indicating whether an element is a descendent of another element.
*/
isDescendent(element1: JQuery | HTMLElement, element2: JQuery | HTMLElement): boolean
/**
* Returns a boolean indicating whether object is undefined or html, body, or document.
*/
isUndefinedOrHTMLBodyDoc(obj: any): boolean
/**
* Returns a boolean indicating whether an object is a DOM element.
*/
isElement(obj: any): boolean
/**
* Returns a boolean indicating whether a node is of document type.
*/
isDocument(obj: any): boolean
/**
* Returns a boolean indicating whether an object is a window object.
*/
isWindow(obj: any): obj is Window
/**
* Returns a boolean indicating whether an object is a jQuery object.
*/
isJquery(obj: any): obj is JQuery
isInputType(element: JQuery | HTMLElement, type: string | string[]): boolean
stringify(element: JQuery | HTMLElement, form: string): string
getElements(element: JQuery): JQuery | HTMLElement[]
getContainsSelector(text: string, filter?: string): JQuery.Selector
getFirstDeepestElement(elements: HTMLElement[], index?: number): HTMLElement
getWindowByElement(element: JQuery | HTMLElement): JQuery | HTMLElement
getReasonIsHidden(element: JQuery | HTMLElement, options?: object): string
getFirstScrollableParent(element: JQuery | HTMLElement): JQuery | HTMLElement
getFirstFixedOrStickyPositionParent(element: JQuery | HTMLElement): JQuery | HTMLElement
getFirstStickyPositionParent(element: JQuery | HTMLElement): JQuery | HTMLElement
getCoordsByPosition(left: number, top: number, xPosition?: string, yPosition?: string): number
getElementPositioning(element: JQuery | HTMLElement): ElementPositioning
getElementAtPointFromViewport(doc: Document, x: number, y: number): Element | null
getElementCoordinatesByPosition(element: JQuery | HTMLElement, position: string): ElementCoordinates
getElementCoordinatesByPositionRelativeToXY(element: JQuery | HTMLElement, x: number, y: number): ElementPositioning
}
/**
* @see https://on.cypress.io/api/api-server
*/
Server: {
defaults(options: Partial<ServerOptions>): void
}
/**
* @see https://on.cypress.io/screenshot-api
*/
Screenshot: {
defaults(options: Partial<ScreenshotDefaultsOptions>): void
}
/**
* These events come from Cypress as it issues commands and reacts to their state. These are all useful to listen to for debugging purposes.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
on: Actions
/**
* These events come from Cypress as it issues commands and reacts to their state. These are all useful to listen to for debugging purposes.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
once: Actions
/**
* These events come from Cypress as it issues commands and reacts to their state. These are all useful to listen to for debugging purposes.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
off: Actions
}
type CanReturnChainable = void | Chainable | Promise<unknown>
type ThenReturn<S, R> =
R extends void ? Chainable<S> :
R extends R | undefined ? Chainable<S | Exclude<R, undefined>> :
Chainable<S>
/**
* Chainable interface for non-array Subjects
*/
interface Chainable<Subject = any> {
/**
* Create an assertion. Assertions are automatically retried until they pass or time out.
*
* @alias should
* @see https://on.cypress.io/and
*/
and: Chainer<Subject>
/**
* Assign an alias for later use. Reference the alias later within a
* [cy.get()](https://on.cypress.io/get) or
* [cy.wait()](https://on.cypress.io/wait) command with a `@` prefix.
* You can alias DOM elements, routes, stubs and spies.
*
* @see https://on.cypress.io/as
* @see https://on.cypress.io/variables-and-aliases
* @see https://on.cypress.io/get
* @example
```
// Get the aliased ‘todos’ elements
cy.get('ul#todos').as('todos')
//...hack hack hack...
// later retrieve the todos
cy.get('@todos')
```
*/
as(alias: string): Chainable<Subject>
/**
* Blur a focused element. This element must currently be in focus.
* If you want to ensure an element is focused before blurring,
* try using .focus() before .blur().
*
* @see https://on.cypress.io/blur
*/
blur(options?: Partial<BlurOptions>): Chainable<Subject>
/**
* Check checkbox(es) or radio(s). This element must be an `<input>` with type `checkbox` or `radio`.
*
* @see https://on.cypress.io/check
* @example
* // Check checkbox element
* cy.get('[type="checkbox"]').check()
* // Check first radio element
* cy.get('[type="radio"]').first().check()
*/
check(options?: Partial<CheckOptions>): Chainable<Subject>
/**
* Check checkbox(es) or radio(s). This element must be an `<input>` with type `checkbox` or `radio`.
*
* @see https://on.cypress.io/check
* @example
* // Select the radio with the value of ‘US’
* cy.get('[type="radio"]').check('US')
* // Check the checkboxes with the values ‘ga’ and ‘ca’
* cy.get('[type="checkbox"]').check(['ga', 'ca'])
*/
check(value: string | string[], options?: Partial<CheckOptions>): Chainable<Subject>
/**
* Get the children of each DOM element within a set of DOM elements.
*
* @see https://on.cypress.io/children
*/
children<E extends Node = HTMLElement>(options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
children<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
children<E extends Node = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Clear the value of an `input` or `textarea`.
* An alias for `.type({selectall}{backspace})`
*
* @see https://on.cypress.io/clear
*/
clear(options?: Partial<ClearOptions>): Chainable<Subject>
/**
* Clear a specific browser cookie.
* Cypress automatically clears all cookies before each test to prevent state from being shared across tests. You shouldn’t need to use this command unless you’re using it to clear a specific cookie inside a single test.
*
* @see https://on.cypress.io/clearcookie
*/
clearCookie(name: string, options?: Partial<Loggable & Timeoutable>): Chainable<null>
/**
* Clear all browser cookies.
* Cypress automatically clears all cookies before each test to prevent state from being shared across tests. You shouldn’t need to use this command unless you’re using it to clear a specific cookie inside a single test.
*
* @see https://on.cypress.io/clearcookies
*/
clearCookies(options?: Partial<Loggable & Timeoutable>): Chainable<null>
/**
* Clear data in local storage.
* Cypress automatically runs this command before each test to prevent state from being
* shared across tests. You shouldn’t need to use this command unless you’re using it
* to clear localStorage inside a single test. Yields `localStorage` object.
*
* @see https://on.cypress.io/clearlocalstorage
* @param {string} [key] - name of a particular item to remove (optional).
* @example
```
// Removes all local storage keys
cy.clearLocalStorage()
.should(ls => {
expect(ls.getItem('prop1')).to.be.null
})
// Removes item "todos"
cy.clearLocalStorage("todos")
```
*/
clearLocalStorage(key?: string): Chainable<Storage>
/**
* Clear keys in local storage that match given regular expression.
*
* @see https://on.cypress.io/clearlocalstorage
* @param {RegExp} re - regular expression to match.
* @example
```
// Clears all local storage matching /app-/
cy.clearLocalStorage(/app-/)
```
*/
clearLocalStorage(re: RegExp): Chainable<Storage>
/**
* Clear data in local storage.
* Cypress automatically runs this command before each test to prevent state from being
* shared across tests. You shouldn’t need to use this command unless you’re using it
* to clear localStorage inside a single test. Yields `localStorage` object.
*
* @see https://on.cypress.io/clearlocalstorage
* @param {options} [object] - options object
* @example
```
// Removes all local storage items, without logging
cy.clearLocalStorage({ log: false })
```
*/
clearLocalStorage(options: Partial<Loggable>): Chainable<Storage>
/**
* Clear data in local storage.
* Cypress automatically runs this command before each test to prevent state from being
* shared across tests. You shouldn’t need to use this command unless you’re using it
* to clear localStorage inside a single test. Yields `localStorage` object.
*
* @see https://on.cypress.io/clearlocalstorage
* @param {string} [key] - name of a particular item to remove (optional).
* @param {options} [object] - options object
* @example
```
// Removes item "todos" without logging
cy.clearLocalStorage("todos", { log: false })
```
*/
clearLocalStorage(key: string, options: Partial<Loggable>): Chainable<Storage>
/**
* Click a DOM element.
*
* @see https://on.cypress.io/click
* @example
* cy.get('button').click() // Click on button
* cy.focused().click() // Click on el with focus
* cy.contains('Welcome').click() // Click on first el containing 'Welcome'
*/
click(options?: Partial<ClickOptions>): Chainable<Subject>
/**
* Click a DOM element at specific corner / side.
*
* @param {PositionType} position - The position where the click should be issued.
* The `center` position is the default position.
* @see https://on.cypress.io/click
* @example
* cy.get('button').click('topRight')
*/
click(position: PositionType, options?: Partial<ClickOptions>): Chainable<Subject>
/**
* Click a DOM element at specific coordinates
*
* @param {number} x The distance in pixels from the element’s left to issue the click.
* @param {number} y The distance in pixels from the element’s top to issue the click.
* @see https://on.cypress.io/click
* @example
```
// The click below will be issued inside of the element
// (15px from the left and 40px from the top).
cy.get('button').click(15, 40)
```
*/
click(x: number, y: number, options?: Partial<ClickOptions>): Chainable<Subject>
/**
* `cy.clock()` overrides native global functions related to time allowing them to be controlled
* synchronously via [cy.tick()](https://on.cypress.io/tick) or the yielded clock object.
* This includes controlling:
* * `setTimeout`
* * `clearTimeout`
* * `setInterval`
* * `clearInterval`
* * `Date` Objects
*
* The clock starts at the unix epoch (timestamp of 0).
* This means that when you instantiate new Date in your application,
* it will have a time of January 1st, 1970.
*
* To restore the real clock call `.restore()`
*
* @example
* cy.clock()
* ...
* // restore the application clock
* cy.clock().then(clock => {
* clock.restore()
* })
* // or use this shortcut
* cy.clock().invoke('restore')
*
* @see https://on.cypress.io/clock
*/
clock(): Chainable<Clock>
/**
* Mocks global clock and sets current timestamp to the given value.
* Overrides all functions that deal with time.
*
* @see https://on.cypress.io/clock
* @example
* // in your app code
* $('#date').text(new Date().toJSON())
* // in the spec file
* // March 14, 2017 timestamp or Date object
* const now = new Date(2017, 2, 14).getTime()
* cy.clock(now)
* cy.visit('/index.html')
* cy.get('#date').contains('2017-03-14')
* // to restore the real clock
* cy.clock().then(clock => {
* clock.restore()
* })
* // or use this shortcut
* cy.clock().invoke('restore')
*/
clock(now: number|Date, options?: Loggable): Chainable<Clock>
/**
* Mocks global clock but only overrides specific functions.
*
* @see https://on.cypress.io/clock
* @example
* // keep current date but override "setTimeout" and "clearTimeout"
* cy.clock(null, ['setTimeout', 'clearTimeout'])
*/
clock(now: number|Date, functions?: Array<'setTimeout' | 'clearTimeout' | 'setInterval' | 'clearInterval' | 'Date'>, options?: Loggable): Chainable<Clock>
/**
* Mocks global clock and all functions.
*
* @see https://on.cypress.io/clock
* @example
* // mock clock but do not log this command
* cy.clock({ log: false })
*/
clock(options: Loggable): Chainable<Clock>
/**
* Get the first DOM element that matches the selector (whether it be itself or one of its ancestors).
*
* @see https://on.cypress.io/closest
*/
closest<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
closest<E extends Node = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get the DOM element containing the text.
* DOM elements can contain more than the desired text and still match.
* Additionally, Cypress prefers some DOM elements over the deepest element found.
*
* @see https://on.cypress.io/contains
* @example
* // Yield el in .nav containing 'About'
* cy.get('.nav').contains('About')
* // Yield first el in document containing 'Hello'
* cy.contains('Hello')
* // you can use regular expression
* cy.contains(/^b\w+/)
* // yields <ul>...</ul>
* cy.contains('ul', 'apples')
* // tries to find the given text for up to 1 second
* cy.contains('my text to find', {timeout: 1000})
*/
contains(content: string | number | RegExp, options?: Partial<Loggable & Timeoutable & CaseMatchable>): Chainable<Subject>
/**
* Get the child DOM element that contains given text.
*
* @see https://on.cypress.io/contains
* @example
* // Yield el in .nav containing 'About'
* cy.get('.nav').contains('About')
*/
contains<E extends Node = HTMLElement>(content: string | number | RegExp): Chainable<JQuery<E>>
/**
* Get the DOM element with name "selector" containing the text or regular expression.
*
* @see https://on.cypress.io/contains
* @example
* // yields <ul>...</ul>
* cy.contains('ul', 'apples')
*/
contains<K extends keyof HTMLElementTagNameMap>(selector: K, text: string | number | RegExp, options?: Partial<Loggable & Timeoutable & CaseMatchable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
/**
* Get the DOM element using CSS "selector" containing the text or regular expression.
*
* @see https://on.cypress.io/contains
* @example
* // yields <... class="foo">... apples ...</...>
* cy.contains('.foo', 'apples')
*/
contains<E extends Node = HTMLElement>(selector: string, text: string | number | RegExp, options?: Partial<Loggable & Timeoutable & CaseMatchable>): Chainable<JQuery<E>>
/**
* Double-click a DOM element.
*
* @see https://on.cypress.io/dblclick
*/
dblclick(options?: Partial<ClickOptions>): Chainable<Subject>
/**
* Double-click a DOM element at specific corner / side.
*
* @param {PositionType} position - The position where the click should be issued.
* The `center` position is the default position.
* @see https://on.cypress.io/dblclick
* @example
* cy.get('button').dblclick('topRight')
*/
dblclick(position: PositionType, options?: Partial<ClickOptions>): Chainable<Subject>
/**
* Double-click a DOM element at specific coordinates
*
* @param {number} x The distance in pixels from the element’s left to issue the click.
* @param {number} y The distance in pixels from the element’s top to issue the click.
* @see https://on.cypress.io/dblclick
* @example
```
// The click below will be issued inside of the element
// (15px from the left and 40px from the top).
cy.get('button').dblclick(15, 40)
```
*/
dblclick(x: number, y: number, options?: Partial<ClickOptions>): Chainable<Subject>
/**
* Right-click a DOM element.
*
* @see https://on.cypress.io/rightclick
*/
rightclick(options?: Partial<ClickOptions>): Chainable<Subject>
/**
* Right-click a DOM element at specific corner / side.
*
* @param {PositionType} position - The position where the click should be issued.
* The `center` position is the default position.
* @see https://on.cypress.io/click
* @example
* cy.get('button').rightclick('topRight')
*/
rightclick(position: PositionType, options?: Partial<ClickOptions>): Chainable<Subject>
/**
* Right-click a DOM element at specific coordinates
*
* @param {number} x The distance in pixels from the element’s left to issue the click.
* @param {number} y The distance in pixels from the element’s top to issue the click.
* @see https://on.cypress.io/rightclick
* @example
```
// The click below will be issued inside of the element
// (15px from the left and 40px from the top).
cy.get('button').rightclick(15, 40)
```
*/
rightclick(x: number, y: number, options?: Partial<ClickOptions>): Chainable<Subject>
/**
* Set a debugger and log what the previous command yields.
*
* @see https://on.cypress.io/debug
*/
debug(options?: Partial<Loggable>): Chainable<Subject>
/**
* Get the window.document of the page that is currently active.
*
* @see https://on.cypress.io/document
* @example
* cy.document()
* .its('contentType')
* .should('eq', 'text/html')
*/
document(options?: Partial<Loggable>): Chainable<Document>
/**
* Iterate through an array like structure (arrays or objects with a length property).
*
* @see https://on.cypress.io/each
*/
each<E extends Node = HTMLElement>(fn: (element: JQuery<E>, index: number, $list: E[]) => void): Chainable<JQuery<E>> // Can't properly infer type without breaking down Chainable
each(fn: (item: any, index: number, $list: any[]) => void): Chainable<Subject>
/**
* End a chain of commands
*
* @see https://on.cypress.io/end
*/
end(): Chainable<null>
/**
* Get A DOM element at a specific index in an array of elements.
*
* @see https://on.cypress.io/eq
* @param {Number} index A number indicating the index to find the element at within an array of elements. A negative number counts index from the end of the list.
* @example
* cy.get('tbody>tr').eq(0) // Yield first 'tr' in 'tbody'
* cy.get('ul>li').eq('4') // Yield fifth 'li' in 'ul'
* cy.get('li').eq(-2) // Yields second from last 'li' element
*/
eq<E extends Node = HTMLElement>(index: number, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Execute a system command.
* @see https://on.cypress.io/exec
*/
exec(command: string, options?: Partial<ExecOptions>): Chainable<Exec>
/**
* Get the DOM elements that match a specific selector. Opposite of `.not()`
*
* @see https://on.cypress.io/filter
*/
filter<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>> // automatically returns the correct HTMLElement type
/**
* Get the DOM elements that match a specific selector. Opposite of `.not()`
*
* @see https://on.cypress.io/filter
*/
filter<E extends Node = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get the DOM elements that match a specific selector. Opposite of `.not()`
*
* @see https://on.cypress.io/filter
*/
filter<E extends Node = HTMLElement>(fn: (index: number, element: E) => boolean, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get the descendent DOM elements of a specific selector.
*
* @see https://on.cypress.io/find
* @example
* cy.get('.article').find('footer') // Yield 'footer' within '.article'
*/
find<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable & Shadow>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
/**
* Finds the descendent DOM elements with the given selector.
*
* @see https://on.cypress.io/find
* @example
* // Find the li’s within the nav
* cy.get('.left-nav>.nav').find('>li')
*/
find<E extends Node = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable & Shadow>): Chainable<JQuery<E>>
/**
* Get the first DOM element within a set of DOM elements.
*
* @see https://on.cypress.io/first
*/
first(options?: Partial<Loggable & Timeoutable>): Chainable<Subject>
/**
* Load a fixed set of data located in a file.
*
* @see https://on.cypress.io/fixture
*/
fixture<Contents = any>(path: string, options?: Partial<Timeoutable>): Chainable<Contents> // no log?
/**
* Load a fixed set of data located in a file with given encoding.
*
* @see https://on.cypress.io/fixture
*/
fixture<Contents = any>(path: string, encoding: Encodings, options?: Partial<Timeoutable>): Chainable<Contents> // no log?
/**
* Focus on a DOM element.
*
* @see https://on.cypress.io/focus
* @example
* cy.get('input').first().focus() // Focus on the first input
*/
focus(options?: Partial<Loggable & Timeoutable>): Chainable<Subject>
/**
* Get the DOM element that is currently focused.
*
* @see https://on.cypress.io/focused
* @example
* // Get the element that is focused
* cy.focused().then(function($el) {
* // do something with $el
* })
* // Blur the element with focus
* cy.focused().blur()
* // Make an assertion on the focused element
* cy.focused().should('have.attr', 'name', 'username')
*/
focused(options?: Partial<Loggable & Timeoutable>): Chainable<JQuery>
/**
* Get one or more DOM elements by node name: input, button, etc.
* @see https://on.cypress.io/get
* @example
* cy.get('input').should('be.disabled')
* cy.get('button').should('be.visible')
*/
get<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable & Withinable & Shadow>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
/**
* Get one or more DOM elements by selector.
* The querying behavior of this command matches exactly how $(…) works in jQuery.
* @see https://on.cypress.io/get
* @example
* cy.get('.list>li') // Yield the <li>'s in <.list>
* 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 & Withinable & Shadow>): Chainable<JQuery<E>>
/**
* Get one or more DOM elements by alias.
* @see https://on.cypress.io/get#Alias
* @example
* // Get the aliased ‘todos’ elements
* cy.get('ul#todos').as('todos')
* //...hack hack hack...
* //later retrieve the todos
* cy.get('@todos')
*/
get<S = any>(alias: string, options?: Partial<Loggable & Timeoutable & Withinable & Shadow>): Chainable<S>
/**
* Get a browser cookie by its name.
*
* @see https://on.cypress.io/getcookie
*/
getCookie(name: string, options?: Partial<Loggable & Timeoutable>): Chainable<Cookie | null>
/**
* Get all of the browser cookies.
*
* @see https://on.cypress.io/getcookies
*/
getCookies(options?: Partial<Loggable & Timeoutable>): Chainable<Cookie[]>
/**
* Navigate back or forward to the previous or next URL in the browser’s history.
*
* @see https://on.cypress.io/go
*/
go(direction: HistoryDirection | number, options?: Partial<Loggable & Timeoutable>): Chainable<AUTWindow>
/**
* Get the current URL hash of the page that is currently active.
*
* @see https://on.cypress.io/hash
*/
hash(options?: Partial<Loggable & Timeoutable>): Chainable<string>
/**
* Invoke a function on the previously yielded subject.
*
* @see https://on.cypress.io/invoke
*/
invoke<K extends keyof Subject, F extends ((...args: any[]) => any) & Subject[K], R = ReturnType<F>>(
functionName: K,
...args: any[]
): Chainable<R>
invoke<K extends keyof Subject, F extends ((...args: any[]) => any) & Subject[K], R = ReturnType<F>>(
options: Partial<Loggable & Timeoutable>,
functionName: K,
...args: any[]
): Chainable<R>
/**
* Invoke a function in an array of functions.
* @see https://on.cypress.io/invoke
*/
invoke<T extends (...args: any[]) => any, Subject extends T[]>(index: number): Chainable<ReturnType<T>>
invoke<T extends (...args: any[]) => any, Subject extends T[]>(options: Partial<Loggable & Timeoutable>, index: number): Chainable<ReturnType<T>>
/**
* Invoke a function on the previously yielded subject by a property path.
* Property path invocation cannot be strongly-typed.
* Invoking by a property path will always result in any.
*
* @see https://on.cypress.io/invoke
*/
invoke(propertyPath: string, ...args: any[]): Chainable
/**
* Get a property’s value on the previously yielded subject.
*
* @see https://on.cypress.io/its
* @example
* // Get the 'width' property
* cy.wrap({width: '50'}).its('width')
* // Drill into nested properties by using dot notation
* cy.wrap({foo: {bar: {baz: 1}}}).its('foo.bar.baz')
*/
its<K extends keyof Subject>(propertyName: K, options?: Partial<Loggable & Timeoutable>): Chainable<Subject[K]>
its(propertyPath: string, options?: Partial<Loggable & Timeoutable>): Chainable
/**
* Get a value by index from an array yielded from the previous command.
* @see https://on.cypress.io/its
* @example
* cy.wrap(['a', 'b']).its(1).should('equal', 'b')
*/
its<T, Subject extends T[]>(index: number, options?: Partial<Loggable & Timeoutable>): Chainable<T>
/**
* Get the last DOM element within a set of DOM elements.
*
* @see https://on.cypress.io/last
*/
last<E extends Node = HTMLElement>(options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get the global `window.location` object of the page that is currently active.
*
* @see https://on.cypress.io/location
* @example
* cy.location() // Get location object
*/
location(options?: Partial<Loggable & Timeoutable>): Chainable<Location>
/**
* Get a part of the global `window.location` object of the page that is currently active.
*
* @see https://on.cypress.io/location
* @example
* cy.location('host') // Get the host of the location object
* cy.location('port') // Get the port of the location object
* // Assert on the href of the location
* cy.location('href').should('contain', '/tag/tutorials')
*/
location<K extends keyof Location>(key: K, options?: Partial<Loggable & Timeoutable>): Chainable<Location[K]>
/**
* Print a message to the Cypress Command Log.
*
* @see https://on.cypress.io/log
*/
log(message: string, ...args: any[]): Chainable<null>
/**
* Get the immediately following sibling of each DOM element within a set of DOM elements.
*
* @see https://on.cypress.io/next
*/
next<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
/**
* Get the immediately following sibling of each DOM element within a set of DOM elements.
*
* @see https://on.cypress.io/next
* @example
* cy.get('nav a:first').next()
*/
next<E extends Node = HTMLElement>(options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get the immediately following sibling of each DOM element within a set of DOM elements that match selector
*
* @see https://on.cypress.io/next
* @example
* cy.get('nav a:first').next('.menu-item)
*/
next<E extends Node = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get all following siblings of each DOM element in a set of matched DOM elements.
*
* @see https://on.cypress.io/nextall
*/
nextAll<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
/**
* Get all following siblings of each DOM element in a set of matched DOM elements.
*
* @see https://on.cypress.io/nextall
*/
nextAll<E extends HTMLElement = HTMLElement>(options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get all following siblings of each DOM element in a set of matched DOM elements.
*
* @see https://on.cypress.io/nextall
*/
nextAll<E extends HTMLElement = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get all following siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
*
* @see https://on.cypress.io/nextuntil
*/
nextUntil<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
/**
* Get all following siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
*
* @see https://on.cypress.io/nextuntil
*/
nextUntil<E extends HTMLElement = HTMLElement>(options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get all following siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
*
* @see https://on.cypress.io/nextuntil
*/
nextUntil<E extends HTMLElement = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Filter DOM element(s) from a set of DOM elements. Opposite of `.filter()`
*
* @see https://on.cypress.io/not
*/
not(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery>
/**
* These events come from Cypress as it issues commands and reacts to their state. These are all useful to listen to for debugging purposes.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
on: Actions
/**
* These events come from Cypress as it issues commands and reacts to their state. These are all useful to listen to for debugging purposes.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
once: Actions
/**
* These events come from Cypress as it issues commands and reacts to their state. These are all useful to listen to for debugging purposes.
* @see https://on.cypress.io/catalog-of-events#App-Events
*/
off: Actions
/**
* Get the parent DOM element of a set of DOM elements.
*
* @see https://on.cypress.io/parent
*/
parent<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
/**
* Get the parent DOM element of a set of DOM elements.
*
* @see https://on.cypress.io/parent
*/
parent<E extends Node = HTMLElement>(options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get the parent DOM element of a set of DOM elements.
*
* @see https://on.cypress.io/parent
*/
parent<E extends Node = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get the parent DOM elements of a set of DOM elements.
*
* @see https://on.cypress.io/parents
*/
parents<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
/**
* Get the parent DOM elements of a set of DOM elements.
*
* @see https://on.cypress.io/parents
*/
parents<E extends Node = HTMLElement>(options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get the parent DOM elements of a set of DOM elements.
*
* @see https://on.cypress.io/parents
*/
parents<E extends Node = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get all ancestors of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
*
* @see https://on.cypress.io/parentsuntil
*/
parentsUntil<K extends keyof HTMLElementTagNameMap>(selector: K, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
/**
* Get all ancestors of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
*
* @see https://on.cypress.io/parentsuntil
*/
parentsUntil<E extends Node = HTMLElement>(selector: string, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Get all ancestors of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
*
* @see https://on.cypress.io/parentsuntil
*/
parentsUntil<E extends Node = HTMLElement>(element: E | JQuery<E>, filter?: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
/**
* Stop cy commands from running and allow interaction with the application under test. You can then "resume" running all commands or choose to step through the "next" commands from the Command Log.
* This does not set a `debugger` in your code, unlike `.debug()`
*
* @see https://on.cypress.io/pause
*/
pause(options?: Partial<Loggable>): Chainable<Subject>
/**
* Get the immediately preceding sibling of each element in a set of the elements.
*
* @example
* cy.get('nav').prev('a') // Yield previous 'a'
* @see https://on.cypress.io/prev
*/
prev<K extends keyof HTMLElementTagNameMap>(selector: K, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<HTMLElementTagNameMap[K]>>
/**
* Get the immediately preceding sibling of each element in a set of the elements.
*
* @example
* cy.get('li').prev() // Yield previous 'li'
* @see https://on.cypress.io/prev
*/
prev<E extends