///
///
///
///
declare namespace Cypress {
type FileContents = string | any[] | object
type HistoryDirection = 'back' | 'forward'
type HttpMethod = string
type RequestBody = string | object | boolean | null
type ViewportOrientation = 'portrait' | 'landscape'
type PrevSubject = keyof PrevSubjectMap
type TestingType = 'e2e' | 'component'
type PluginConfig = (on: PluginEvents, config: PluginConfigOptions) => void | ConfigOptions | Promise
interface JQueryWithSelector extends JQuery {
selector?: string | null
}
interface PrevSubjectMap {
optional: O
element: JQueryWithSelector
document: Document
window: Window
}
interface CommandOptions {
prevSubject: boolean | PrevSubject | PrevSubject[]
}
interface CommandFn {
(this: Mocha.Context, ...args: Parameters): ReturnType | void
}
interface CommandFns {
[name: string]: (this: Mocha.Context, ...args: any) => any
}
interface CommandFnWithSubject {
(this: Mocha.Context, prevSubject: S, ...args: Parameters): ReturnType | void
}
interface CommandFnsWithSubject {
[name: string]: (this: Mocha.Context, prevSubject: S, ...args: any) => any
}
interface CommandOriginalFn extends CallableFunction {
(...args: Parameters): ReturnType
}
interface CommandOriginalFnWithSubject extends CallableFunction {
(prevSubject: S, ...args: Parameters): ReturnType
}
interface CommandFnWithOriginalFn {
(this: Mocha.Context, originalFn: CommandOriginalFn, ...args: Parameters): ReturnType | void
}
interface CommandFnWithOriginalFnAndSubject {
(this: Mocha.Context, originalFn: CommandOriginalFnWithSubject, prevSubject: S, ...args: Parameters): ReturnType | void
}
interface QueryFn {
(this: Command, ...args: Parameters): (subject: any) => any
}
interface QueryFnWithOriginalFn {
(this: Command, originalFn: QueryFn, ...args: Parameters): (subject: any) => any
}
interface ObjectLike {
[key: string]: any
}
interface PromptOptions {
placeholders?: Record
}
interface Auth {
username: string
password: string
}
interface RemoteState {
auth?: Auth
domainName: string
strategy: 'file' | 'http'
origin: string
fileServer: string | null
props: Record | null
}
interface Backend {
(task: 'net', eventName: string, frame: any): Promise
}
/**
* Trigger action
* @private
*/
interface ActionTrigger {
(action: string, ...args: any[]): T
}
type BrowserName = 'electron' | 'chrome' | 'chromium' | 'firefox' | 'edge' | string
type BrowserChannel = 'stable' | 'canary' | 'beta' | 'dev' | 'nightly' | string
type BrowserFamily = 'chromium' | 'firefox' | 'webkit'
/**
* 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 | string
path: string
isHeaded: boolean
isHeadless: boolean
/**
* Informational text to accompany this browser. Shown in desktop-gui.
*/
info?: string
/**
* Warning text to accompany this browser. Shown in desktop-gui.
*/
warning?: string
/**
* If `true`, this browser version is not supported in Cypress.
*/
unsupportedVersion?: boolean
}
/**
* Browser that's exposed in public APIs
*/
interface PublicBrowser {
channel: BrowserChannel
displayName: string
family: string
majorVersion?: string | number | null
name: BrowserName
path: string
version: string
}
interface Ensure {
/**
* Throws an error if `subject` is not one of the passed in `type`s.
*/
isType(subject: any, type: PrevSubject[], commandName: string, cy: Chainable): void
/**
* Throws an error if `subject` is not a DOM element.
*/
isElement(subject: any, commandName: string, cy: Chainable): void
/**
* Throws an error if `subject` is not a `document`.
*/
isDocument(subject: any, commandName: string, cy: Chainable): void
/**
* Throws an error if `subject` is not a `window`.
*/
isWindow(subject: any, commandName: string, cy: Chainable): void
/**
* Throws an error if `subject` is not a DOM element attached to the application under test.
*/
isAttached(subject: any, commandName: string, cy: Chainable, onFail?: Log): void
/**
* Throws an error if `subject` is a disabled DOM element.
*/
isNotDisabled(subject: any, commandName: string, onFail?: Log): void
/**
* Throws an error if `subject` is a DOM element hidden by any of its parent elements.
*/
isNotHiddenByAncestors(subject: any, commandName: string, onFail?: Log): void
/**
* Throws an error if `subject` is a read-only form element.
*/
isNotReadonly(subject: any, commandName: string, onFail?: Log): void
/**
* Throws an error if `subject` is a read-only form element.
*/
isScrollable(subject: any, commandName: string, onFail?: Log): void
/**
* Throws an error if `subject` is not a DOM element visible in the AUT.
*/
isVisible(subject: any, commandName: string, onFail?: Log): void
}
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
}
// TODO: raise minimum required TypeScript version to 3.7
// and make this recursive
// https://github.com/cypress-io/cypress/issues/24875
type Storable =
| string
| number
| boolean
| null
| StorableObject
| StorableArray
interface StorableObject {
[key: string]: Storable
}
interface StorableArray extends Array { }
type StorableRecord = Record
interface OriginStorage {
origin: string
value: StorableRecord
}
interface Storages {
localStorage: OriginStorage[]
sessionStorage: OriginStorage[]
}
interface StorageByOrigin {
[key: string]: StorableRecord
}
type IsBrowserMatcher = BrowserName | Partial | Array>
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 `open --component` 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/e2e/config_passing_spec.cy.js" or "__all" if clicked all specs button
absolute: string // "/Users/janelane/app/cypress/e2e/config_passing_spec.cy.js"
specFilter?: string // optional spec filter used by the user
specType?: CypressSpecType
baseName?: string // "config_passing_spec.cy.js"
fileExtension?: string // ".js"
fileName?: string // "config_passing_spec.cy"
id?: string // "U3BlYzovVXNlcnMvamFuZWxhbmUvYXBwL2N5cHJlc3MvZTJlL2NvbmZpZ19wYXNzaW5nX3NwZWMuY3kuanM="
}
/**
* Window type for Application Under Test(AUT)
*/
type AUTWindow = Window & typeof globalThis & ApplicationWindow
/**
* The object yielded by `cy.location()`, describing the current URL of the Application Under Test (AUT).
* It is a plain object, not the AUT's `window.location`, so it has no methods such as `assign()` or `reload()`.
*
* @see https://on.cypress.io/location
*/
interface AUTLocation {
hash: string
host: string
hostname: string
href: string
origin: string
pathname: string
port: string
protocol: string
search: string
searchParams: URLSearchParams
}
/**
* The interface for user-defined properties in Window object under test.
*/
interface ApplicationWindow { } // tslint:disable-line
/**
* The configuration for Cypress.
*/
type Config = ResolvedConfigOptions & RuntimeConfigOptions & RuntimeServerConfigOptions
/**
* 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 a Buffer library and exposes it as Cypress.Buffer.
*
* @see https://on.cypress.io/buffer
* @see https://github.com/feross/buffer
* @example
* Cypress.Buffer.method()
*/
Buffer: BufferType
/**
* Cypress automatically includes minimatch and exposes it as Cypress.minimatch.
*
* @see https://on.cypress.io/minimatch
*/
minimatch: typeof Minimatch.minimatch
/**
* 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
/**
* Utility functions for ensuring various properties about a subject.
* @see https://on.cypress.io/api/custom-queries
*/
ensure: Ensure
/**
* 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.cy.ts",
* // relative: "cypress/e2e/config_passing.cy.ts",
* // absolute: "/users/smith/projects/web/cypress/e2e/config_passing.cy.ts"
* // specType: "integration"
* // }
* ```
*/
spec: Spec
/**
* Currently executing test runnable instance.
*/
currentTest: {
title: string
titlePath: string[]
}
/**
* Information about current test retry
*/
currentRetry: number
/**
* Information about the browser currently running the tests
*/
browser: Browser
/**
* Internal class for LocalStorage management.
*/
LocalStorage: LocalStorage
/**
* Internal class for session management.
*/
session: Session
/**
* Current testing type, determined by the Test Runner chosen to run.
*/
testingType: TestingType
/**
* Fire automation:request event for internal use.
*/
automation(eventName: string, ...args: any[]): Bluebird.Promise
/**
* 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(): Config
/**
* Returns one configuration value.
* @see https://on.cypress.io/config
* @example
```
Cypress.config('pageLoadTimeout')
// 60000
```
*/
config(key: K): Config[K]
/**
* Sets one configuration value.
* @see https://on.cypress.io/config
* @example
```
Cypress.config('viewportWidth', 800)
```
*/
config(key: K, value: TestConfigOverrides[K]): void
/**
* Sets multiple configuration values at once.
* @see https://on.cypress.io/config
* @example
```
Cypress.config({
defaultCommandTimeout: 10000,
viewportHeight: 900
})
```
*/
config(Object: TestConfigOverrides): void
/**
* Returns all exposed public configuration variables set with --expose in the CLI or in "expose" object in "cypress.config.{js,ts,mjs,cjs}"
*
* @see https://on.cypress.io/expose
*/
expose(): ObjectLike
/**
* Returns specific exposed public configuration variable or undefined
* @see https://on.cypress.io/expose
* @example
* // cypress.config.js
* { "expose": { "foo": "bar" } }
* Cypress.expose("foo") // => bar
*/
expose(key: string): any
/**
* Set value for an exposed public configuration variable.
* Any value you change will be permanently changed for the remainder of your tests.
* @see https://on.cypress.io/expose
* @example
* Cypress.expose("host", "http://server.dev.local")
*/
expose(key: string, value: any): void
/**
* Set values for multiple exposed public configuration variables at once. Values are merged with existing values.
* @see https://on.cypress.io/expose
* @example
* Cypress.expose({ host: "http://server.dev.local", foo: "foo" })
*/
expose(object: ObjectLike): void
/**
* @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(obj: Chainable): obj is Chainable
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 name 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): Log
/**
* Stop the Cypress App on the current machine while tests are running
* @see https://on.cypress.io/cypress-stop
* @example
* Cypress.stop()
*/
stop(): void
Commands: Commands
/**
* @see https://on.cypress.io/cookies
*/
Cookies: {
debug(enabled: boolean, options?: Partial): 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
/**
* Returns the elements matching a jQuery selector, as a jQuery object.
* Without a `context`, it searches the document that Cypress's own scripts
* run in, not your application. To search your application, pass its
* document or an element in it as `context`.
* @example
* cy.document().then((doc) => {
* const $buttons = Cypress.dom.query('button', doc)
* })
*/
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
/**
* 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.
* Accepts a DOM element or a jQuery object. For a jQuery object with
* more than one element, returns `true` if any of them can receive focus.
*/
isFocusable(element: JQuery | HTMLElement): boolean
/**
* Returns a boolean indicating whether an element accepts typed text: a
* `