Classdes

CypressHelper exposes the following public properties:

Hierarchy

  • CypressHelper

Constructors

Properties

get: {
    assertableStub: ((stub) => Chainable<JQuery<any>>);
    bySelector: ((selector, attribute?) => Chainable<JQuery<HTMLElement>>);
    currentLocation: (() => Chainable<string>);
    element: ((selector, index?) => Chainable<JQuery<HTMLElement>>);
    elementByAttribute: ((attribute, selector) => Chainable<JQuery<HTMLElement>>);
    elementBySelector: ((selector, attribute?) => Chainable<JQuery<HTMLElement>>);
    elementByTestId: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>);
    elementByText: ((content, index?) => Chainable<undefined> | Chainable<JQuery<HTMLElement>>);
    elementsAttribute: ((dataTestID, attributeName, index?) => Chainable<undefined | string>);
    elementsComputedStyle: ((dataTestID, index?, pseudoElement?) => Chainable<CSSStyleDeclaration>);
    elementsProperty: ((dataTestID, propertyName, index?) => Chainable<any>);
    elementsStyleAttribute: ((dataTestID, attributeName, index?) => Chainable<PlainObject<string>>);
    elementsText: ((dataTestID, index?) => Chainable<string>);
    env: ((key) => any);
    fixture: ((alias) => Chainable<any>);
    focusedElement: (() => Chainable<JQuery<HTMLElement>>);
    inputValue: ((dataTestID, index?) => Chainable<string | number | string[]>);
    nthBySelector: ((selector, index?, attribute?) => Chainable<JQuery<HTMLElement>>);
    numberOfElements: ((dataTestID) => Chainable<number>);
    requestBody: ((alias) => Chainable<any>);
    requestHeader: ((alias) => Chainable<{
        [key: string]: string | string[];
    }>);
    requestQueryParams: ((alias) => Chainable<{
        [k: string]: string;
    }>);
    requestUrl: ((alias) => Chainable<string>);
    responseBody: ((alias) => Chainable<any>);
    responseHeader: ((alias) => Chainable<{
        [key: string]: string | string[];
    }>);
    spy: ((name) => Chainable<JQuery<HTMLElement>>);
    spyFromFunction: ((func) => Chainable<JQuery<HTMLElement>>);
    stub: ((name) => Chainable<JQuery<HTMLElement>>);
    window: (() => Chainable<AUTWindow>);
} = ...

The get property will hold methods which will give our tests access to the “output” of the component in a “black box” fashion

Type declaration

  • assertableStub: ((stub) => Chainable<JQuery<any>>)
      • (stub): Chainable<JQuery<any>>
      • Get stub as Cypress.Chainable

        Parameters

        • stub: any

        Returns Chainable<JQuery<any>>

        Example

        const serviceMock : Service = helper.given.stubbedInstance(Service);
        helper.get.assertableStub(serviceMock.function).should('have.been.called'));

        @deprecated The method should not be used anymore, use `then` instead
        ```ts
        then(serviceMock.function).shouldHaveBeenCalled();
  • bySelector: ((selector, attribute?) => Chainable<JQuery<HTMLElement>>)
      • (selector, attribute?): Chainable<JQuery<HTMLElement>>
      • Get one or more DOM elements by selector.

        Parameters

        • selector: string
        • Optional attribute: string = ...

        Returns Chainable<JQuery<HTMLElement>>

        Example

        Get an element with shape="filter-grid"

        <clr-icon shape="filter-grid"></clr-icon>
        helper.get.bySelector("filter-grid", "shape")
  • currentLocation: (() => Chainable<string>)
      • (): Chainable<string>
      • Get the current URL of the page that is currently active.

        Returns Chainable<string>

  • element: ((selector, index?) => Chainable<JQuery<HTMLElement>>)
      • (selector, index?): Chainable<JQuery<HTMLElement>>
      • Get one or more DOM elements by selector. The querying behavior of this command matches exactly how $(…) works in jQuery. *** Note! Using this method may lead to flakey tests! You should use get.elementByTestId ***

        Parameters

        • selector: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

        Example

        get.element('.list>li', 3)    // Yield the <li>'s in <.list>
        get.element('ul li:first')
        get.element('.dropdown-menu')
  • elementByAttribute: ((attribute, selector) => Chainable<JQuery<HTMLElement>>)
      • (attribute, selector): Chainable<JQuery<HTMLElement>>
      • Get one or more DOM elements by attribute.

        Parameters

        • attribute: string
        • selector: string

        Returns Chainable<JQuery<HTMLElement>>

        Example

        Get an element with shape="filter-grid"

        <clr-icon shape="filter-grid"></clr-icon>
        helper.get.byAttribute("shape", "filter-grid")
  • elementBySelector: ((selector, attribute?) => Chainable<JQuery<HTMLElement>>)
      • (selector, attribute?): Chainable<JQuery<HTMLElement>>
      • Get one or more DOM elements by selector. Same as bySelector

        Parameters

        • selector: string
        • Optional attribute: string = ...

        Returns Chainable<JQuery<HTMLElement>>

        Example

        Get an element with shape="filter-grid"

        <clr-icon shape="filter-grid"></clr-icon>
        helper.get.elementBySelector("filter-grid", "shape")
  • elementByTestId: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>)
      • (dataTestID, index?): Chainable<JQuery<HTMLElement>>
      • Get A DOM element at a specific index from elements.

        Parameters

        • dataTestID: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

        Example

        helper.when.dragAndDrop(
        helper.get.elementByTestId('selected-item', 2),
        helper.get.elementByTestId('available-items')
  • elementByText: ((content, index?) => Chainable<undefined> | Chainable<JQuery<HTMLElement>>)
      • (content, index?): Chainable<undefined> | Chainable<JQuery<HTMLElement>>
      • 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. *** Note! Using this method may lead to flakey tests! You should use get.elementByTestId ***

        Parameters

        • content: string | RegExp
        • Optional index: number

        Returns Chainable<undefined> | Chainable<JQuery<HTMLElement>>

        Example

        then(helper.get.elementByText("Avamar")).shouldExist();
        
  • elementsAttribute: ((dataTestID, attributeName, index?) => Chainable<undefined | string>)
      • (dataTestID, attributeName, index?): Chainable<undefined | string>
      • Parameters

        • dataTestID: string
        • attributeName: string
        • Optional index: number

        Returns Chainable<undefined | string>

        Example

        then(helper.get.elementsAttribute('avatar-picture', 'style')).shouldInclude('background-image: url("assets/avatar/def-user-male.png")')
        
  • elementsComputedStyle: ((dataTestID, index?, pseudoElement?) => Chainable<CSSStyleDeclaration>)
      • (dataTestID, index?, pseudoElement?): Chainable<CSSStyleDeclaration>
      • Returns element's computed style, including pseudo elements

        Parameters

        • dataTestID: string
        • Optional index: number
        • Optional pseudoElement: string

        Returns Chainable<CSSStyleDeclaration>

        Example

        helper.get.elementsComputedStyle('element-test-id', 0, ':before')
        
  • elementsProperty: ((dataTestID, propertyName, index?) => Chainable<any>)
      • (dataTestID, propertyName, index?): Chainable<any>
      • Get element's property value

        Parameters

        • dataTestID: string
        • propertyName: keyof JQuery<HTMLElement>
        • Optional index: number

        Returns Chainable<any>

        Example

        get.elementsProperty("image", "height")
        
  • elementsStyleAttribute: ((dataTestID, attributeName, index?) => Chainable<PlainObject<string>>)
      • (dataTestID, attributeName, index?): Chainable<PlainObject<string>>
      • Returns element's style attribute

        Parameters

        • dataTestID: string
        • attributeName: string
        • Optional index: number

        Returns Chainable<PlainObject<string>>

        Example

        get.elementsStyleAttribute("button-data-hook", "background-color")
        
  • elementsText: ((dataTestID, index?) => Chainable<string>)
      • (dataTestID, index?): Chainable<string>
      • Parameters

        • dataTestID: string
        • Optional index: number

        Returns Chainable<string>

        Example

        then(helper.get.elementsText("parent-job-name", 3)).shouldInclude("Job 3 Name")
        
  • env: ((key) => any)
      • (key): any
      • Returns specific environment variable or undefined

        Parameters

        • key: string

        Returns any

        Example

        // Keeping password in cypress.config file

        e2e: {
        env: {
        password: "Changeme@1",
        }
        }

        // using password during test

        helper.get.env("password");
        
  • fixture: ((alias) => Chainable<any>)
      • (alias): Chainable<any>
      • Get fixture

        Parameters

        • alias: string

        Returns Chainable<any>

        Example

         given.fixture("user.json", "user");
        then(
        get.fixture("user").shouldDeepNestedInclude({
        name: "Jane Doe",
        id: "1234",
        nested: {
        attr1: "something",
        attr2: "the other thing"
        }
        })
        );
  • focusedElement: (() => Chainable<JQuery<HTMLElement>>)
      • (): Chainable<JQuery<HTMLElement>>
      • Get the element currently focused in the document.

        Returns Chainable<JQuery<HTMLElement>>

  • inputValue: ((dataTestID, index?) => Chainable<string | number | string[]>)
      • (dataTestID, index?): Chainable<string | number | string[]>
      • Get value of input element

        Parameters

        • dataTestID: string
        • Optional index: number

        Returns Chainable<string | number | string[]>

        Example

        then(helper.get.inputValue('credentials-password')).shouldEqual("initial password");
        
  • nthBySelector: ((selector, index?, attribute?) => Chainable<JQuery<HTMLElement>>)
      • (selector, index?, attribute?): Chainable<JQuery<HTMLElement>>
      • Get A DOM element at a specific index from elements.

        Parameters

        • selector: string
        • Optional index: number
        • Optional attribute: string = ...

        Returns Chainable<JQuery<HTMLElement>>

        Example

        // Get the 3rd checkbox

        helper.get.nthBySelector("checkbox", 3, "type")
        
  • numberOfElements: ((dataTestID) => Chainable<number>)
      • (dataTestID): Chainable<number>
      • Get number of elements with a specific dataTestID

        Parameters

        • dataTestID: string

        Returns Chainable<number>

        Example

         then(helper.get.numberOfElements("migrated-vcenter")).shouldEqual(2);
        
  • requestBody: ((alias) => Chainable<any>)
      • (alias): Chainable<any>
      • Get intercepted request's body If a JSON Content-Type was used and the body was valid JSON, this will be an object. If the body was binary content, this will be a buffer.

        Parameters

        • alias: string

        Returns Chainable<any>

  • requestHeader: ((alias) => Chainable<{
        [key: string]: string | string[];
    }>)
      • (alias): Chainable<{
            [key: string]: string | string[];
        }>
      • Get intercepted request's header

        Parameters

        • alias: string

        Returns Chainable<{
            [key: string]: string | string[];
        }>

  • requestQueryParams: ((alias) => Chainable<{
        [k: string]: string;
    }>)
      • (alias): Chainable<{
            [k: string]: string;
        }>
      • Get intercepted request's query param

        Parameters

        • alias: string

        Returns Chainable<{
            [k: string]: string;
        }>

  • requestUrl: ((alias) => Chainable<string>)
      • (alias): Chainable<string>
      • Get intercepted request's url

        Parameters

        • alias: string

        Returns Chainable<string>

  • responseBody: ((alias) => Chainable<any>)
      • (alias): Chainable<any>
      • Get intercepted response's body If a JSON Content-Type was used and the body was valid JSON, this will be an object. If the body was binary content, this will be a buffer.

        Parameters

        • alias: string

        Returns Chainable<any>

  • responseHeader: ((alias) => Chainable<{
        [key: string]: string | string[];
    }>)
      • (alias): Chainable<{
            [key: string]: string | string[];
        }>
      • Get intercepted response's header

        Parameters

        • alias: string

        Returns Chainable<{
            [key: string]: string | string[];
        }>

  • spy: ((name) => Chainable<JQuery<HTMLElement>>)
      • (name): Chainable<JQuery<HTMLElement>>
      • Get spy by alias

        Parameters

        • name: string

        Returns Chainable<JQuery<HTMLElement>>

  • spyFromFunction: ((func) => Chainable<JQuery<HTMLElement>>)
      • (func): Chainable<JQuery<HTMLElement>>
      • Get spy by function name alias

        Parameters

        • func: Function

        Returns Chainable<JQuery<HTMLElement>>

  • stub: ((name) => Chainable<JQuery<HTMLElement>>)
      • (name): Chainable<JQuery<HTMLElement>>
      • Get stub by alias

        Parameters

        • name: string

        Returns Chainable<JQuery<HTMLElement>>

  • window: (() => Chainable<AUTWindow>)
      • (): Chainable<AUTWindow>
      • Get the window object of the page that is currently active.

        Returns Chainable<AUTWindow>

        Example

        helper.get.window().then((win) => { win.localStorage.getItem("key")}
        
given: {
    fixture: ((filename, alias) => Chainable<any>);
    intercept: ((url, alias, method?) => void);
    interceptAndMockResponse: ((options) => void);
    spy: ((name) => Omit<SinonSpy<any[], any>, "withArgs"> & SinonSpyAgent<SinonSpy<any[], any>> & SinonSpy<any[], any>);
    spyOnObject: (<T>(obj, method) => Omit<SinonSpy<any[], any>, "withArgs"> & SinonSpyAgent<SinonSpy<any[], any>> & SinonSpy<any[], any>);
    stub: ((alias?) => Agent<SinonStub<any[], any>>);
    stubObjectMethod: (<T>(obj, method) => Omit<SinonStub<any[], any>, "withArgs"> & SinonSpyAgent<SinonStub<any[], any>> & SinonStub<any[], any>);
    stubbedInstance: (<T>(constructor, overrides?) => StubbedInstance<T, SinonStub<any[], any>> & T);
    stubbedInterface: (<T>(interfaceName, overrides?) => StubbedInstance<T, SinonStub<any[], any>> & T);
} = ...

The given property will hold methods which will allow us to set pre-conditions before something takes place. This is a classic place to have methods which will set the inputs which are going to be passed down to our component.

Type declaration

  • fixture: ((filename, alias) => Chainable<any>)
      • (filename, alias): Chainable<any>
      • Load a fixture

        Parameters

        • filename: string
        • alias: string

        Returns Chainable<any>

        Example

        let { given, when, get } = new CypressHelper();
        it("should get fixture", () => {
        given.fixture("user.json", "user");
        then(get.fixture("user")).shouldDeepNestedInclude({
        name: "Jane Doe",
        id: "1234",
        nested: {
        attr1: "something",
        attr2: "the other thing"
        }
        });
        });
  • intercept: ((url, alias, method?) => void)
      • (url, alias, method?): void
      • Use intercept() to intercept HTTP requests and responses

        Parameters

        • url: string
        • alias: string
        • Optional method: string

        Returns void

        Example

        helper.given.intercept("/streets/sprite.png", "streetSprite");
        
  • interceptAndMockResponse: ((options) => void)
      • (options): void
      • Use interceptAndMockResponse to stub and intercept HTTP requests and responses.

        Parameters

        • options: {
              alias?: string;
              method?: string;
              response?: Object;
              url: StringMatcher;
          }
          • Optional alias?: string
          • Optional method?: string
          • Optional response?: Object
          • url: StringMatcher

        Returns void

        Example

        // adds token to response header

        helper.given.interceptAndMockResponse({
        url: '** /sysmgmt/2015/bmc/session',
        response: {
        headers:{
        'XSRF-Token': 'token',
        },
        },
        alias: 'login'
        })

        Example

        // mocks response to login request

        helper.given.interceptAndMockResponse({
        method: "POST",
        url: "** /login",
        alias: "login",
        response : {
        token: 'token'
        }
        })

        Example

        // mocks network error

        helper.given.interceptAndMockResponse({
        method: "POST",
        url: "** /avamars",
        alias: "avamar",
        response : {
        forceNetworkError: true
        }
        })

        Example

        // mocks missing image

        helper.given.interceptAndMockResponse({
        method: "POST",
        url: "** /image.png",
        alias: "image",
        response: { headers: 404 }
        })

        Example

        // using a fixture

         helper.given.interceptAndMockResponse({
        url: "** /shellygo/whatever**",
        response: { fixture: "user.json" },
        alias: "whatever"
        });
  • spy: ((name) => Omit<SinonSpy<any[], any>, "withArgs"> & SinonSpyAgent<SinonSpy<any[], any>> & SinonSpy<any[], any>)
      • (name): Omit<SinonSpy<any[], any>, "withArgs"> & SinonSpyAgent<SinonSpy<any[], any>> & SinonSpy<any[], any>
      • Returns a new spy function, and creates an alias for the newly created spy

        Parameters

        • name: string

          spy name

        Returns Omit<SinonSpy<any[], any>, "withArgs"> & SinonSpyAgent<SinonSpy<any[], any>> & SinonSpy<any[], any>

  • spyOnObject: (<T>(obj, method) => Omit<SinonSpy<any[], any>, "withArgs"> & SinonSpyAgent<SinonSpy<any[], any>> & SinonSpy<any[], any>)
      • <T>(obj, method): Omit<SinonSpy<any[], any>, "withArgs"> & SinonSpyAgent<SinonSpy<any[], any>> & SinonSpy<any[], any>
      • Spy on a method and create an alias for the spy

        Type Parameters

        • T

        Parameters

        • obj: T

          object containing function to spy on

        • method: keyof T

          function to spy on

        Returns Omit<SinonSpy<any[], any>, "withArgs"> & SinonSpyAgent<SinonSpy<any[], any>> & SinonSpy<any[], any>

        Example

        given.spyOnObject(window, "alert");
        alert("whatever");
        then(helper.get.spyFromFunction(window.alert)).shouldHaveBeenCalledWith("whatever");
        // Or
        then(helper.get.spy("alert")).shouldHaveBeenCalledTimes(1);

        Example

        given.spyOnObject(serviceMock, "functionName");
        serviceMock.functionName();
        then(helper.get.spyFromFunction(serviceMock.functionName)).shouldHaveBeenCalledTimes(1);
  • stub: ((alias?) => Agent<SinonStub<any[], any>>)
      • (alias?): Agent<SinonStub<any[], any>>
      • Replace a function, record its usage and control its behavior.

        Parameters

        • Optional alias: string

        Returns Agent<SinonStub<any[], any>>

        Example

        given.stub("alias");
        then(get.spy("alias")).shouldHaveBeenCalled();
  • stubObjectMethod: (<T>(obj, method) => Omit<SinonStub<any[], any>, "withArgs"> & SinonSpyAgent<SinonStub<any[], any>> & SinonStub<any[], any>)
      • <T>(obj, method): Omit<SinonStub<any[], any>, "withArgs"> & SinonSpyAgent<SinonStub<any[], any>> & SinonStub<any[], any>
      • Stub an object's method and create an alias for the stub

        Type Parameters

        • T

        Parameters

        • obj: T

          object containing function to stub

        • method: keyof T

          function to stub

        Returns Omit<SinonStub<any[], any>, "withArgs"> & SinonSpyAgent<SinonStub<any[], any>> & SinonStub<any[], any>

        Example

        //stubbing a service method
        helper.given.stubObjectMethod(serviceMock, "functionName").returns(3);

        //stubbing setters and getters
        helper.given.stubObjectMethod(serviceMock, "count").get(() => 3).set(() => {});
  • stubbedInstance: (<T>(constructor, overrides?) => StubbedInstance<T, SinonStub<any[], any>> & T)
      • <T>(constructor, overrides?): StubbedInstance<T, SinonStub<any[], any>> & T
      • Creates a new object with the given functions as the prototype and stubs all implemented functions.

        Type Parameters

        • T

        Parameters

        • constructor: (new (...args) => T)
            • new (...args): T
            • Parameters

              • Rest ...args: any[]

              Returns T

        • overrides: Partial<T> = {}

        Returns StubbedInstance<T, SinonStub<any[], any>> & T

        Example

        const serviceMock = helper.given.stubbedInstance(Service);
        

        Example

        class Service {
        public func1() {...}
        public get prop1() {...}
        }
        const serviceMock = helper.given.stubbedInstance(Service, {prop1: 3});

        Example

        helper.given.stubbedInstance(Router, { events: new Observable() })
        

        Example

        helper.given.stubbedInstance(
        PokemonService,
        {
        pokemonTypes: new BehaviorSubject<NamedAPIResource[]>([]),
        pokemons: new BehaviorSubject<BetterPokemon[]>([]),
        }
        )
  • stubbedInterface: (<T>(interfaceName, overrides?) => StubbedInstance<T, SinonStub<any[], any>> & T)
      • <T>(interfaceName, overrides?): StubbedInstance<T, SinonStub<any[], any>> & T
      • Creates a new object with the given functions as the prototype and stubs all functions.

        Type Parameters

        • T extends Object

        Parameters

        • interfaceName: string
        • overrides: Partial<T> = {}

        Returns StubbedInstance<T, SinonStub<any[], any>> & T

        Example

        const serviceMock = helper.given.stubbedInterface<IService>("IService");
        

        Example

        interface IService {
        propertyFunc: (int: number) => number
        get prop1() : number
        }
        const serviceMock = helper.given.stubbedInterface<IService>("IService", {prop1: 3});
options: CypressHelperOptions = {}
when: {
    acceptConfirm: (() => EventEmitter2 | Listener);
    blur: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>);
    cancelConfirm: (() => Cypress);
    cancelPrompt: (() => EventEmitter2 | Listener);
    check: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>);
    clear: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>);
    click: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>);
    clock: (() => Chainable<Clock>);
    closeAlert: (() => Cypress);
    dblclick: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>);
    doWithin: ((fn, dataTestID, index?) => Chainable<JQuery<HTMLElement>>);
    dragAndDrop: ((element, targetElement) => void);
    focus: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>);
    hover: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>);
    realClick: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>);
    realType: ((dataTestID, keys, index?) => Chainable<void>);
    rightclick: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>);
    scrollToBottom: (() => Chainable<undefined>);
    selectOption: ((dataTestID, option, index?) => Chainable<JQuery<HTMLElement>>);
    tick: ((ms) => Chainable<Clock>);
    toggle: ((index) => Chainable<JQuery<HTMLElement>>);
    toggleRadioBySelector: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>);
    type: ((dataTestID, keys, index?) => Chainable<JQuery<HTMLElement>>);
    typeSpecialCharacter: ((dataTestID, keys, index?) => Chainable<JQuery<HTMLElement>>);
    uncheck: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>);
    visit: ((url) => void);
    wait: ((ms) => Chainable<undefined>);
    waitForLastCall: ((alias, timeout?) => Chainable<undefined | Interception>);
    waitForResponse: ((alias) => Chainable<Interception>);
    waitForResponses: ((alias, responses) => Chainable<Interception[]>);
    waitUntil: (<ReturnType>(checkFunction, options?) => Chainable<undefined>);
    within: ((fn, dataTestID, index?) => Chainable<JQuery<HTMLElement>>);
} = ...

The when property will hold methods of “events” which will take place like render, click, hover, etc.

Type declaration

  • acceptConfirm: (() => EventEmitter2 | Listener)
      • (): EventEmitter2 | Listener
      • Fires when your app calls the global window.confirm() method. The confirmation will be accepted.

        Returns EventEmitter2 | Listener

  • blur: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>)
      • (dataTestID, index?): Chainable<JQuery<HTMLElement>>
      • Blur a focused element. This element must currently be in focus. If you want to ensure an element is focused before blurring, try using helper.when.focus() before helper.when.blur().

        Parameters

        • dataTestID: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

  • cancelConfirm: (() => Cypress)
      • (): Cypress
      • Fires when your app calls the global window.confirm() method. The confirmation will be canceled.

        Returns Cypress

  • cancelPrompt: (() => EventEmitter2 | Listener)
      • (): EventEmitter2 | Listener
      • Fires when your app calls the global window.prompt() method. The prompt will be cancelled.

        Returns EventEmitter2 | Listener

  • check: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>)
      • (dataTestID, index?): Chainable<JQuery<HTMLElement>>
      • Check checkbox(es) or radio(s). This element must be an html input element with type checkbox or radio.

        Parameters

        • dataTestID: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

  • clear: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>)
      • (dataTestID, index?): Chainable<JQuery<HTMLElement>>
      • Clear the value of an input or textarea

        Parameters

        • dataTestID: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

  • click: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>)
      • (dataTestID, index?): Chainable<JQuery<HTMLElement>>
      • Click a DOM element.

        Parameters

        • dataTestID: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

        Example

        <button data-cy="move-right">Move</button>
        helper.when.click('move-right')
  • clock: (() => Chainable<Clock>)
      • (): Chainable<Clock>
      • overrides native global functions related to time allowing them to be controlled synchronously via helper.when.tick() 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.

        Returns Chainable<Clock>

  • closeAlert: (() => Cypress)
      • (): Cypress
      • Fires when your app calls the global window.alert() method. The alert will be closed.

        Returns Cypress

  • dblclick: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>)
      • (dataTestID, index?): Chainable<JQuery<HTMLElement>>
      • Double-click a DOM element.

        Parameters

        • dataTestID: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

  • doWithin: ((fn, dataTestID, index?) => Chainable<JQuery<HTMLElement>>)
      • (fn, dataTestID, index?): Chainable<JQuery<HTMLElement>>
      • Scopes the execution of a function within an element

        Parameters

        • fn: (() => void)
            • (): void
            • Returns void

        • dataTestID: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

        Example

        helper.when.doWithin(() => when.click('button-test-id'), 'button-row', 2)
        
  • dragAndDrop: ((element, targetElement) => void)
      • (element, targetElement): void
      • Drag an element and drop it in target element

        Parameters

        • element: Chainable<JQuery<HTMLElement>>

          element to be dragged

        • targetElement: Chainable<JQuery<HTMLElement>>

          target of drag operation

        Returns void

        Example

        helper.when.dragAndDrop(
        helper.get.elementByTestId('selected-item', 2),
        helper.get.elementByTestId('available-items')
        )
  • focus: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>)
      • (dataTestID, index?): Chainable<JQuery<HTMLElement>>
      • Focus on a DOM element.

        Parameters

        • dataTestID: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

        Example

        helper.when.focus('credentials-password')
        
  • hover: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>)
      • (dataTestID, index?): Chainable<JQuery<HTMLElement>>
      • Fires native hover event. Yes, it can test :hover preprocessor.

        Parameters

        • dataTestID: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

        Example

        helper.when.hover('consent-terms-agree')
        
  • realClick: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>)
      • (dataTestID, index?): Chainable<JQuery<HTMLElement>>
      • Fires native system click event.

        Parameters

        • dataTestID: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

        Example

        <button data-cy="move-right">Move</button>
        helper.when.realClick('move-right')
  • realType: ((dataTestID, keys, index?) => Chainable<void>)
      • (dataTestID, keys, index?): Chainable<void>
      • Runs a sequence of native press event (via cy.press) Type event is global. Make sure that it is not attached to any field.

        Parameters

        • dataTestID: string
        • keys: string
        • Optional index: number

        Returns Chainable<void>

  • rightclick: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>)
      • (dataTestID, index?): Chainable<JQuery<HTMLElement>>
      • Right click a DOM element.

        Parameters

        • dataTestID: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

  • scrollToBottom: (() => Chainable<undefined>)
      • (): Chainable<undefined>
      • Scroll to the bottom.

        Returns Chainable<undefined>

  • selectOption: ((dataTestID, option, index?) => Chainable<JQuery<HTMLElement>>)
      • (dataTestID, option, index?): Chainable<JQuery<HTMLElement>>
      • Select an option with specific text, value, or index within a select html element.

        Parameters

        • dataTestID: string
        • option: string | number
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

        Example

        <select data-hook="fruit-selection">
        <option value="456">apples</option>
        <option value="457">oranges</option>
        <option value="458">bananas</option>
        </select>
        helper.when.selectOption('fruit-selection', 0).should('have.value', '456')
        helper.when.selectOption('fruit-selection', 'oranges').should('have.value', '457')
        helper.when.selectOption('fruit-selection', 458).should('have.value', '458')
  • tick: ((ms) => Chainable<Clock>)
      • (ms): Chainable<Clock>
      • Move time after overriding a native time function with helper.when.clock(). helper.when.clock() must be called before helper.when.tick()

        Parameters

        • ms: number

        Returns Chainable<Clock>

        Example

        helper.when.clock();
        helper.when.click('login-button');
        helper.when.tick(2000);
  • toggle: ((index) => Chainable<JQuery<HTMLElement>>)
      • (index): Chainable<JQuery<HTMLElement>>
      • Check radio(s). This element must be an html input element with type radio.

        Parameters

        • index: number

        Returns Chainable<JQuery<HTMLElement>>

  • toggleRadioBySelector: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>)
      • (dataTestID, index?): Chainable<JQuery<HTMLElement>>
      • Toggle radio(s) by dataTestID This element must be an html input element with type radio.

        Parameters

        • dataTestID: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

  • type: ((dataTestID, keys, index?) => Chainable<JQuery<HTMLElement>>)
      • (dataTestID, keys, index?): Chainable<JQuery<HTMLElement>>
      • Type into a DOM element, not including special characters

        Parameters

        • dataTestID: string
        • keys: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

        Example

        helper.when.type('credentials-password', 'new password')
        
  • typeSpecialCharacter: ((dataTestID, keys, index?) => Chainable<JQuery<HTMLElement>>)
      • (dataTestID, keys, index?): Chainable<JQuery<HTMLElement>>
      • Type into a DOM element, including special characters

        Parameters

        • dataTestID: string
        • keys: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

        Example

        helper.when.typeSpecialChar('credentials-password', '{backspace}')
        
  • uncheck: ((dataTestID, index?) => Chainable<JQuery<HTMLElement>>)
      • (dataTestID, index?): Chainable<JQuery<HTMLElement>>
      • Uncheck checkbox(es).

        Parameters

        • dataTestID: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

  • visit: ((url) => void)
      • (url): void
      • Visit a given url

        Parameters

        • url: string

        Returns void

  • wait: ((ms) => Chainable<undefined>)
      • (ms): Chainable<undefined>
      • Wait for a number of milliseconds.

        Parameters

        • ms: number

        Returns Chainable<undefined>

  • waitForLastCall: ((alias, timeout?) => Chainable<undefined | Interception>)
      • (alias, timeout?): Chainable<undefined | Interception>
      • Wait for a last request to complete.

        Parameters

        • alias: string
        • timeout: number = 1000

        Returns Chainable<undefined | Interception>

  • waitForResponse: ((alias) => Chainable<Interception>)
      • (alias): Chainable<Interception>
      • Wait for a specific request to complete.

        Parameters

        • alias: string

        Returns Chainable<Interception>

  • waitForResponses: ((alias, responses) => Chainable<Interception[]>)
      • (alias, responses): Chainable<Interception[]>
      • Wait for multiples requests to complete.

        Parameters

        • alias: string
        • responses: number

        Returns Chainable<Interception[]>

  • waitUntil: (<ReturnType>(checkFunction, options?) => Chainable<undefined>)
      • <ReturnType>(checkFunction, options?): Chainable<undefined>
      • Wait for something to happen in the DOM. Note! you should not have any asserts in the callback function. From cypress-wait-until documentation: you cannot put assertions inside checkFunction. There is no way to avoid a test failure if an assertion throws an error. You must manually check what the assertions would check for you. The most common case is checking that an element exists or not

        Type Parameters

        • ReturnType = any

        Parameters

        • checkFunction: (() => Chainable<any> | ReturnType | PromiseLike<ReturnType>)
            • (): Chainable<any> | ReturnType | PromiseLike<ReturnType>
            • Returns Chainable<any> | ReturnType | PromiseLike<ReturnType>

        • Optional options: WaitUntilOptions<any>

        Returns Chainable<undefined>

        Example

        helper.when.waitUntil(() =>
        helper.get.elementByTestId('element-test-id', index)
        );
  • within: ((fn, dataTestID, index?) => Chainable<JQuery<HTMLElement>>)
      • (fn, dataTestID, index?): Chainable<JQuery<HTMLElement>>
      • Scopes the execution of a function within an element

        Parameters

        • fn: (() => void)
            • (): void
            • Returns void

        • dataTestID: string
        • Optional index: number

        Returns Chainable<JQuery<HTMLElement>>

        Example

        helper.when.within(() => when.click('button-test-id'), 'button-row', 2)
        

        Deprecated

        The method should not be used anymore. Use helper.when.doWithin instead.

Methods

  • Returns void

  • Type Parameters

    • T

    Parameters

    • constructor: StubbableType<T>
    • prop: keyof T

    Returns undefined | boolean

  • Type Parameters

    • T

    Parameters

    • constructor: StubbableType<T>
    • prop: keyof T

    Returns undefined | boolean

  • Type Parameters

    • T

    Parameters

    • checkFunction: (() => Chainable<T>)
        • (): Chainable<T>
        • Returns Chainable<T>

    • Optional options: WaitUntilOptions<any>

    Returns Chainable<T>

Generated using TypeDoc