// Project: https://www.cypress.io // GitHub: https://github.com/cypress-io/cypress // Definitions by: Gert Hengeveld // Mike Woudenberg // Robbert van Markus // Nicholas Boll // TypeScript Version: 2.8 // Updated by the Cypress team: https://www.cypress.io/about/ /// /// /// /// /// /// /// /// /// /// /// // "moment" types are with "node_modules/moment" /// // load ambient declaration for "cypress" NPM module // hmm, how to load it better? /// // Cypress adds chai expect and assert to global declare const expect: Chai.ExpectStatic declare const assert: Chai.AssertStatic 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" interface CommandOptions { prevSubject: boolean | PrevSubject | PrevSubject[] } interface ObjectLike { [key: string]: any } interface Auth { username: string password: string } /** * Describes a browser Cypress can control */ interface Browser { name: "electron" | "chrome" | "canary" | "chromium" | "firefox" displayName: "Electron" | "Chrome" | "Canary" | "Chromium" | "FireFox" version: string majorVersion: string 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 } /** * 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 /** * 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 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" // } ``` */ spec: { name: string // "config_passing_spec.coffee" relative: string | null // "cypress/integration/config_passing_spec.coffee" absolute: string | null } /** * Information about the browser currently running the tests */ browser: Browser /** * Internal class for LocalStorage management. */ LocalStorage: LocalStorage /** * Returns all configuration objects. * @see https://on.cypress.io/config * @example ``` Cypress.config() // {defaultCommandTimeout: 10000, pageLoadTimeout: 30000, ...} ``` */ config(): ConfigOptions /** * Returns one configuration value. * @see https://on.cypress.io/config * @example ``` Cypress.config('pageLoadTimeout') // 60000 ``` */ config(key: K): ConfigOptions[K] /** * Sets one configuration value. * @see https://on.cypress.io/config * @example ``` Cypress.config('viewportWidth', 800) ``` */ config(key: K, value: ConfigOptions[K]): void /** * Sets multiple configuration values at once. * @see https://on.cypress.io/config * @example ``` Cypress.config({ defaultCommandTimeout: 10000, viewportHeight: 900 }) ``` */ config(Object: Partial): 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 /** * 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 /** * Internal options for "cy.log" used in custom commands. * * @see https://on.cypress.io/cypress-log */ log(options: Partial): Log /** * @see https://on.cypress.io/api/commands */ Commands: { add(name: string, fn: (...args: any[]) => void): void add(name: string, options: CommandOptions, fn: (...args: any[]) => void): void overwrite(name: string, fn: (...args: any[]) => void): void overwrite(name: string, options: CommandOptions, fn: (...args: any[]) => void): void } /** * @see https://on.cypress.io/cookies */ Cookies: { debug(enabled: boolean, options?: Partial): void preserveOnce(...names: string[]): void defaults(options: Partial): void } /** * @see https://on.cypress.io/dom */ dom: { isHidden(element: JQuery | HTMLElement): boolean } /** * @see https://on.cypress.io/api/api-server */ Server: { defaults(options: Partial): void } /** * @see https://on.cypress.io/api/screenshot-api */ Screenshot: { defaults(options: Partial): 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 */ off: Actions } /** * Chainable interface for non-array Subjects */ interface Chainable { /** * Create an assertion. Assertions are automatically retried until they pass or time out. * * @alias should * @see https://on.cypress.io/and */ and: Chainer /** * 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 /** * 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): Chainable /** * Check checkbox(es) or radio(s). This element must be an `` 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): Chainable /** * Check checkbox(es) or radio(s). This element must be an `` 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): Chainable /** * Get the children of each DOM element within a set of DOM elements. * * @see https://on.cypress.io/children */ children(options?: Partial): Chainable> children(selector: K, options?: Partial): Chainable> children(selector: string, options?: Partial): Chainable> /** * Clear the value of an `input` or `textarea`. * An alias for `.type({selectall}{backspace})` * * @see https://on.cypress.io/clear */ clear(options?: Partial): Chainable /** * 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): Chainable /** * 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): Chainable /** * 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 /** * Clear keys in local storage that match given regular expression. * * @see https://on.cypress.io/clearlocalstorage * @param {RegExp} re - regular expression to match. * @example ``` // Clear all local storage matching /app-/ cy.clearLocalStorage(/app-/) ``` */ clearLocalStorage(re: RegExp): Chainable /** * 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): Chainable /** * Click a DOM element at specific corner / side. * * @param {String} 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: string, options?: Partial): Chainable /** * 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): Chainable /** * `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. * * @see https://on.cypress.io/clock */ clock(): Chainable /** * 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 * // your app code * $('#date').text(new Date().toJSON()) * // from spec file * const now = new Date(2017, 3, 14).getTime() // March 14, 2017 timestamp * cy.clock(now) * cy.visit('/index.html') * cy.get('#date').contains('2017-03-14') */ clock(now: number, options?: Loggable): Chainable /** * 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, functions?: Array<'setTimeout' | 'clearTimeout' | 'setInterval' | 'clearInterval' | 'Date'>, options?: Loggable): Chainable /** * 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 /** * 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(selector: K, options?: Partial): Chainable> closest(selector: string, options?: Partial): Chainable> /** * 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
    ...
* cy.contains('ul', 'apples') */ contains(content: string | number | RegExp): Chainable /** * 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(content: string | number | RegExp): Chainable> /** * Get the DOM element with name "selector" containing the text or regular expression. * * @see https://on.cypress.io/contains * @example * // yields
    ...
* cy.contains('ul', 'apples') */ contains(selector: K, text: string | number | RegExp, options?: Partial): Chainable> /** * 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(selector: string, text: string | number | RegExp, options?: Partial): Chainable> /** * Double-click a DOM element. * * @see https://on.cypress.io/dblclick */ dblclick(options?: Partial): Chainable /** * Set a debugger and log what the previous command yields. * * @see https://on.cypress.io/debug */ debug(options?: Partial): Chainable /** * 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): Chainable /** * Iterate through an array like structure (arrays or objects with a length property). * * @see https://on.cypress.io/each */ each(fn: (element: JQuery, index: number, $list: E[]) => void): Chainable> // Can't properly infer type without breaking down Chainable each(fn: (item: any, index: number, $list: any[]) => void): Chainable /** * End a chain of commands * * @see https://on.cypress.io/end */ end(): Chainable /** * 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(index: number, options?: Partial): Chainable> /** * Execute a system command. * @see https://on.cypress.io/exec */ exec(command: string, options?: Partial): Chainable /** * Get the DOM elements that match a specific selector. Opposite of `.not()` * * @see https://on.cypress.io/filter */ filter(selector: K, options?: Partial): Chainable> // 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(selector: string, options?: Partial): Chainable> /** * Get the DOM elements that match a specific selector. Opposite of `.not()` * * @see https://on.cypress.io/filter */ filter(fn: (index: number, element: E) => boolean, options?: Partial): Chainable> /** * 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(selector: K, options?: Partial): Chainable> /** * 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(selector: string, options?: Partial): Chainable> /** * Get the first DOM element within a set of DOM elements. * * @see https://on.cypress.io/first */ first(options?: Partial): Chainable /** * Load a fixed set of data located in a file. * * @see https://on.cypress.io/fixture */ fixture(path: string, options?: Partial): Chainable // no log? /** * Load a fixed set of data located in a file with given encoding. * * @see https://on.cypress.io/fixture */ fixture(path: string, encoding: Encodings, options?: Partial): Chainable // 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): Chainable /** * 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): Chainable /** * 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(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. * @see https://on.cypress.io/get * @example * cy.get('.list>li') // Yield the
  • 's in <.list> * cy.get('ul li:first').should('have.class', 'active') * cy.get('.dropdown-menu').click() */ get(selector: string, options?: Partial): Chainable> /** * 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(alias: string, options?: Partial): Chainable /** * Get a browser cookie by its name. * * @see https://on.cypress.io/getcookie */ getCookie(name: string, options?: Partial): Chainable /** * Get all of the browser cookies. * * @see https://on.cypress.io/getcookies */ getCookies(options?: Partial): Chainable /** * 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): Chainable /** * Get the current URL hash of the page that is currently active. * * @see https://on.cypress.io/hash */ hash(options?: Partial): Chainable /** * Invoke a function on the previously yielded subject. * This isn't possible to strongly type without generic override yet. * If called on an object you can do this instead: `.then(s => s.show())`. * If called on an array you can do this instead: `.each(s => s.show())`. * From there the subject will be properly typed. * * @see https://on.cypress.io/invoke */ invoke(functionName: keyof Subject, ...args: any[]): Chainable // don't have a way to express return types yet /** * 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(propertyName: K): Chainable /** * Get the last DOM element within a set of DOM elements. * * @see https://on.cypress.io/last */ last(options?: Partial): Chainable> /** * 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): Chainable /** * 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 */ location(key: string, options?: Partial): Chainable /** * Print a message to the Cypress Command Log. * * @see https://on.cypress.io/log */ log(message: string, ...args: any[]): Chainable /** * Get the immediately following sibling of each DOM element within a set of DOM elements. * * @see https://on.cypress.io/next */ next(selector: K, options?: Partial): Chainable> /** * 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(options?: Partial): Chainable> /** * 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(selector: string, options?: Partial): Chainable> /** * Get all following siblings of each DOM element in a set of matched DOM elements. * * @see https://on.cypress.io/nextall */ nextAll(selector: K, options?: Partial): Chainable> /** * Get all following siblings of each DOM element in a set of matched DOM elements. * * @see https://on.cypress.io/nextall */ nextAll(options?: Partial): Chainable> /** * Get all following siblings of each DOM element in a set of matched DOM elements. * * @see https://on.cypress.io/nextall */ nextAll(selector: string, options?: Partial): Chainable> /** * 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(selector: K, options?: Partial): Chainable> /** * 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(options?: Partial): Chainable> /** * 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(selector: string, options?: Partial): Chainable> /** * Filter DOM element(s) from a set of DOM elements. Opposite of `.filter()` * * @see https://on.cypress.io/not */ not(selector: string, options?: Partial): Chainable /** * 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 */ off: Actions /** * Get the parent DOM element of a set of DOM elements. * * @see https://on.cypress.io/parent */ parent(selector: K, options?: Partial): Chainable> /** * Get the parent DOM element of a set of DOM elements. * * @see https://on.cypress.io/parent */ parent(options?: Partial): Chainable> /** * Get the parent DOM element of a set of DOM elements. * * @see https://on.cypress.io/parent */ parent(selector: string, options?: Partial): Chainable> /** * Get the parent DOM elements of a set of DOM elements. * * @see https://on.cypress.io/parents */ parents(selector: K, options?: Partial): Chainable> /** * Get the parent DOM elements of a set of DOM elements. * * @see https://on.cypress.io/parents */ parents(options?: Partial): Chainable> /** * Get the parent DOM elements of a set of DOM elements. * * @see https://on.cypress.io/parents */ parents(selector: string, options?: Partial): Chainable> /** * 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(selector: K, filter?: string, options?: Partial): Chainable> /** * 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(selector: string, filter?: string, options?: Partial): Chainable> /** * 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(element: E | JQuery, filter?: string, options?: Partial): Chainable> /** * 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): Chainable /** * 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(selector: K, options?: Partial): Chainable> /** * 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(options?: Partial): Chainable> /** * Get the immediately preceding sibling of each element in a set of the elements that match selector. * * @example * cy.get('nav').prev('.menu-item') // Yield previous '.menu-item' * @see https://on.cypress.io/prev */ prev(selector: string, options?: Partial): Chainable> /** * Get all previous siblings of each DOM element in a set of matched DOM elements. * > The querying behavior of this command matches exactly how [.prevAll()](http://api.jquery.com/prevAll) works in jQuery. * * @see https://on.cypress.io/prevall */ prevAll(selector: K, options?: Partial): Chainable> /** * Get all previous siblings of each DOM element in a set of matched DOM elements. * > The querying behavior of this command matches exactly how [.prevAll()](http://api.jquery.com/prevAll) works in jQuery. * * @see https://on.cypress.io/prevall */ prevAll(options?: Partial): Chainable> /** * Get all previous siblings of each DOM element in a set of matched DOM elements. * > The querying behavior of this command matches exactly how [.prevAll()](http://api.jquery.com/prevAll) works in jQuery. * * @see https://on.cypress.io/prevall */ prevAll(selector: string, options?: Partial): Chainable> /** * Get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided. * > The querying behavior of this command matches exactly how [.prevUntil()](http://api.jquery.com/prevUntil) works in jQuery. * * @see https://on.cypress.io/prevall */ prevUntil(selector: K, filter?: string, options?: Partial): Chainable> /** * Get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided. * > The querying behavior of this command matches exactly how [.prevUntil()](http://api.jquery.com/prevUntil) works in jQuery. * * @see https://on.cypress.io/prevall */ prevUntil(selector: string, filter?: string, options?: Partial): Chainable> /** * Get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided. * > The querying behavior of this command matches exactly how [.prevUntil()](http://api.jquery.com/prevUntil) works in jQuery. * * @see https://on.cypress.io/prevall */ prevUntil(element: E | JQuery, filter?: string, options?: Partial): Chainable> /** * Read a file and yield its contents. * * @see https://on.cypress.io/readfile */ readFile(filePath: string, options?: Partial): Chainable /** * Read a file with given encoding and yield its contents. * * @see https://on.cypress.io/readfile * @example * cy.readFile('foo.json', 'utf8') */ readFile(filePath: string, encoding: Encodings, options?: Partial): Chainable /** * Reload the page. * * @see https://on.cypress.io/reload * @example * cy.reload() */ reload(options?: Partial): Chainable /** * Reload the page without cache * * @see https://on.cypress.io/reload * @param {Boolean} forceReload Whether to reload the current page without using the cache. true forces the reload without cache. * @example * // Reload the page without using the cache * cy.visit('http://localhost:3000/admin') * cy.reload(true) */ reload(forceReload: boolean): Chainable /** * Make an HTTP GET request. * * @see https://on.cypress.io/request * @example * cy.request('http://dev.local/seed') */ request(url: string, body?: RequestBody): Chainable /** * Make an HTTP request with specific method. * * @see https://on.cypress.io/request * @example * cy.request('POST', 'http://localhost:8888/users', {name: 'Jane'}) */ request(method: HttpMethod, url: string, body?: RequestBody): Chainable /** * Make an HTTP request with specific behavior. * * @see https://on.cypress.io/request * @example * cy.request({ * url: '/dashboard', * followRedirect: false // turn off following redirects * }) */ request(options: Partial): Chainable /** * Get the root DOM element. * The root element yielded is `` by default. * However, when calling `.root()` from a `.within()` command, * the root element will point to the element you are “within”. * * @see https://on.cypress.io/root */ root(options?: Partial): Chainable> // can't do better typing unless we ignore the `.within()` case /** * Use `cy.route()` to manage the behavior of network requests. * * @see https://on.cypress.io/route * @example * cy.server() * cy.route('https://localhost:7777/users', [{id: 1, name: 'Pat'}]) */ route(url: string | RegExp, response?: string | object): Chainable /** * Spy or stub request with specific method and url. * * @see https://on.cypress.io/route * @example * cy.server() * // spy on POST /todos requests * cy.route('POST', '/todos').as('add-todo') */ route(method: string, url: string | RegExp, response?: string | object): Chainable /** * Set a route by returning an object literal from a callback function. * Functions that return a Promise will automatically be awaited. * * @see https://on.cypress.io/route * @example * cy.server() * cy.route(() => { * // your logic here * // return an appropriate routing object here * return { * method: 'POST', * url: '/comments', * response: this.commentsFixture * } * }) */ route(fn: () => RouteOptions): Chainable /** * Spy or stub a given route. * * @see https://on.cypress.io/route * @example * cy.server() * cy.route({ * method: 'DELETE', * url: '/users', * status: 412, * delay: 1000 * // and other options, see documentation * }) */ route(options: Partial): Chainable /** * Take a screenshot of the application under test and the Cypress Command Log. * * @see https://on.cypress.io/screenshot * @example * cy.screenshot() * cy.get(".post").screenshot() */ screenshot(options?: Partial): Chainable /** * Take a screenshot of the application under test and the Cypress Command Log and save under given filename. * * @see https://on.cypress.io/screenshot * @example * cy.get(".post").screenshot("post-element") */ screenshot(fileName: string, options?: Partial): Chainable /** * Scroll an element into view. * * @see https://on.cypress.io/scrollintoview */ scrollIntoView(options?: Partial): Chainable /** * Scroll to a specific position. * * @see https://on.cypress.io/scrollto */ scrollTo(position: PositionType, options?: Partial): Chainable /** * Scroll to a specific X,Y position. * * @see https://on.cypress.io/scrollto */ scrollTo(x: number | string, y: number | string, options?: Partial): Chainable /** * Select an `