// Generated by dts-bundle-generator v7.2.0 import axe from 'axe-core'; import { Options as AxeOptions } from 'cypress-axe'; export type A11yOptions = { /** * Allows you to define a callback that receives the violations for custom side-effects, such as adding custom output to the terminal. */ violationCallback?: ((violations: axe.Result[]) => void) | undefined; /** * Disables assertions based on violations and only logs violations to the console output. */ skipFailures?: boolean; } & AxeOptions; /** Assertable wraps Cypress.Chainable so that your tests are as decoupled as possible from Cypress. * By using the Assertable class, you can use the same assertions in your tests, regardless of the testing framework you use. * All you need to do if you wish to replace Cypress with another testing framework and keep your tests, is to replace the implementation of the Assertable class. * You can also add assertions of your own, by extending Assertable class. * @example * ```ts * import { Assertable, CypressHelper, then } from "@shellygo/cypress-test-utils"; * * class MyAssertable extends Assertable { * private styleFromWindow = (win: Window) => { * const styleItem = win.localStorage.getItem(`style`); * return JSON.parse(styleItem || ""); * }; * * public shouldEqualToStoredStyle = () => * then( * new CypressHelper().get.window().then((win) => { * const style = styleFromWindow(win); * then(this.chainable).shouldDeepNestedInclude(style); * }) * ); * } * * class Driver { * public given = { * // your code here * }; * public when = { * // your code here * }; * public get = { * // your code here * }; * public then = (chainable: Cypress.Chainable) => new MyAssertable(chainable); * } * ``` */ export declare class Assertable { /** private */ protected readonly chainable: Cypress.Chainable; constructor( /** private */ chainable: Cypress.Chainable); should: (chainer: string, ...rest: any[]) => Cypress.Chainable; /** * * Assert that the selection is not empty. * Note that this overrides the built-in chai assertion. * If the object asserted against is not a jQuery object, the original implementation will be called. * @example * ```ts * then(get.elementByTestId("selector")).shouldExist() * ``` */ shouldExist: () => Cypress.Chainable; /** * Assert that the selection is empty. * Note that this overrides the built-in chai assertion. * If the object asserted against is not a jQuery object, the original implementation will be called. * @example * ```ts * then(get.elementByTestId("selector")).shouldNotExist() * ``` */ shouldNotExist: () => Cypress.Chainable; /** * Asserts that the target's length property is equal to the given number n.. * @example * ```ts * then(get.elementByTestId("selector")).shouldHaveLength(3) * ``` */ shouldHaveLength: (length: number) => Cypress.Chainable; /** * When the target is a string, `.include` asserts that the given string val is a substring of the target. * @example * ```ts * then(helper.get.elementsText('selector)).shouldContain('test') * ``` */ shouldInclude: (value: any) => Cypress.Chainable; /** * When the target is a string, `not.include` asserts that the given string val is not a substring of the target. * @example * ```ts * then(helper.get.elementsText('selector)).shouldNotContain('test') * ``` */ shouldNotInclude: (value: any) => Cypress.Chainable; /** * Asserts that text ends with value * @example * ```ts * then(helper.get.elementsText('selector)).shouldEndWith('test') * ``` */ /** * When the target is a string, shouldNotInclude asserts that the given string val is not a substring of the target. * @example * ```ts * then(helper.get.elementsText('selector)).shouldNotInclude('test') * ``` */ shouldNotContain: (value: any) => Cypress.Chainable; /** * shouldNotHaveText asserts that the given string val is not a substring of the target. * @example * ```ts * then(helper.get.elementsText('selector)).shouldNotHaveText('test') * ``` */ shouldNotHaveText: (value: string) => Cypress.Chainable; /** * Asserts that text ends with value * @example * ```ts * then(helper.get.elementsText('selector)).shouldEndWith('test') * ``` */ shouldEndWith: (value: string) => Cypress.Chainable; /** * Asserts that text starts with value * @example * ```ts * then(helper.get.elementsText('selector)).shouldStartWith('test') * ``` */ shouldStartWith: (value: string) => Cypress.Chainable; /** * Causes all `.equal`, `.include`, `.members`, `.keys`, and `.property` assertions that follow in the chain to use deep equality instead of strict (`===`) equality. See the `deep-eql` project page for info on the deep equality algorithm: https://github.com/chaijs/deep-eql. * @example * ```ts * then( * get.fixture("user")).shouldDeepEqual({ * name: "Jane Doe", * id: "1234" * }) * ``` */ shouldDeepEqual: (value: any) => Cypress.Chainable; /** * Asserts that the target has a property with the given key `name`. * @example * ```ts * then( * get.fixture("user")).shouldDeepNestedInclude({ * name: "Jane Doe", * id: "1234", * nested: { * attr1: "something", * attr2: "the other thing" * } * }) * ``` */ shouldDeepNestedInclude: (value: any) => Cypress.Chainable; /** * * Assert that at least one element of the selection is focused. * @example * ```ts * then(get.elementByTestId("selector")).shouldBeFocused() * ``` */ shouldBeFocused: () => Cypress.Chainable; /** * * Assert that no element of the selection is focused. * @example * ```ts * then(get.elementByTestId("selector")).shouldNotBeFocused() * ``` */ shouldNotBeFocused: () => Cypress.Chainable; /** * * Assert that at least one element of the selection is visible, using .is(':visible'). * @example * ```ts * then(get.elementByTestId("selector")).shouldBeVisible() * ``` */ shouldBeVisible: () => Cypress.Chainable; /** * * Assert that at least one element of the selection is not visible, using .is(':visible'). * @example * ```ts * then(get.elementByTestId("selector")).shouldNotBeVisible() * ``` */ shouldNotBeVisible: () => Cypress.Chainable; /** * Assert that the text of the first element of the selection partially contains the given text, using .text(). * @example * ```ts * then(get.elementByTestId("selector")).shouldContainText("test") * ``` */ shouldContainText: (text: string) => Cypress.Chainable; /** Assert that at least one element of the selection is selected, using .is(':selected'). * @example * ```ts * then(get.elementByTestId("selector")).shouldBeSelected() * ``` */ shouldBeSelected: () => Cypress.Chainable; /** * Assert that at least one element of the selection is not selected, using .is(':selected'). * @example * ```ts * then(get.elementByTestId("selector")).shouldNotBeSelected() * ``` */ shouldNotBeSelected: () => Cypress.Chainable; /** Assert that the first element of the selection has the given value, using .val(). * @example * ```ts * then(get.elementByTestId("selector")).shouldHaveValue("test") * ``` */ shouldHaveValue: (value: string) => Cypress.Chainable; /** * Assert that at least one element of the selection is disabled, using `.is(':disabled')`. * @example * ```ts * then(get.elementByTestId("selector")).shouldBeDisabled() * ``` */ shouldBeDisabled: () => Cypress.Chainable; /** * Assert that at least one element of the selection is enabled, using `.is(':enabled')`. * @example * ```ts * then(get.elementByTestId("selector")).shouldBeEnabled() * ``` */ shouldBeEnabled: () => Cypress.Chainable; /** * Asserts that the target is strictly (`===`) equal to the given `val`. * @example * ```ts * then(get.inputValue("name-input")).shouldEqual("John") * ``` */ shouldEqual: (value: any) => Cypress.Chainable; /** * Asserts that the target is a number or a date greater than the given number or date n respectively. * However, it's often best to assert that the target is equal to its expected value. * @example * ```ts * then(get.numberOfElements("radio")).shouldBeGreaterThan(5); * ``` */ shouldBeGreaterThan: (value: number) => Cypress.Chainable; /** Asserts that the target is a number or a n date less than or equal to the given number or date n respectively. However, it's often best to assert that the target is equal to its expected value. * @example * ```ts * then(get.numberOfElements("radio")).shouldBeLessThen(5); * ``` */ shouldBeLessThan: (value: number) => Cypress.Chainable; /** Asserts that the target is a number or a date greater than or equal to the given number or date n respectively. However, it's often best to assert that the target is equal to its expected value. * @example * ```ts * then(get.numberOfElements("radio")).shouldBeGreaterThanOrEqual(5); * ``` */ shouldBeGreaterThanOrEqual: (value: number) => Cypress.Chainable; /** * Asserts that the target is a number or a date less than or equal to the given number or date n respectively. * However, it's often best to assert that the target is equal to its expected value. * @example * then(get.numberOfElements('list-item')).shouldBeLessThanOrEqual(5) */ shouldBeLessThanOrEqual: (value: number) => Cypress.Chainable; /** Assert that at least one element of the selection is checked, using .is(':checked'). * @example * ```ts * then(get.elementByTestId("checkbox-selector")).shouldBeChecked() * ``` */ shouldBeChecked: () => Cypress.Chainable; /** Assert that at least one element of the selection is not checked, using .is(':checked'). * @example * ```ts * then(get.elementByTestId("checkbox-selector")).shouldNotBeChecked() * ``` */ shouldNotBeChecked: () => Cypress.Chainable; /** * * Assert that there are no A11y violations. * This will run axe against the document at the point in which it is called. * This means you can call this after interacting with your page and uncover accessibility issues introduced as a result of rendering in response to user actions * @param options Set of options passed into rules or checks, temporarily modifying them. * This enabled you to see violations while allowing your tests to pass. This should be used as a temporary measure while you address accessibility violations * @example * ```ts * then(get.element("html")).shouldBeAccessible() * ``` * @example * ```ts * then(get.elementByTestId("selector")).shouldBeAccessible({ * includedImpacts: ["critical", "minor"], * rules: { * "landmark-one-main": { enabled: false } * } * }) * ``` */ shouldBeAccessible: (options?: A11yOptions) => void; /** * Assert that the text of the first element of the selection is equal to the given text, using .text(). * @example * ```ts * then(get.elementByTestId("selector")).shouldHaveText("test") * ``` */ shouldHaveText: (value: string) => Cypress.Chainable; /** * Assert that the selection has the given CSS class. * @example * ```ts * then(get.elementByTestId("selector")).shouldHaveClass("test") * ``` */ shouldHaveClass: (value: string) => Cypress.Chainable; /** * Assert that the first element of the selection has the given attribute, using `.attr()`. * Optionally, assert a particular value as well. The return value is available for chaining. * @example * ```ts * then(get.elementByTestId("selector")).shouldHaveAttribute("test") * ``` */ shouldHaveAttribute: (attribute: string, expectedValue?: string) => Cypress.Chainable; /** * Assert that the first element of the selection does not has the given attribute, using `.attr()`. * Optionally, assert a particular value as well. The return value is available for chaining. * @example * ```ts * then(get.elementByTestId("selector")).shouldNotHaveAttribute("test") * ``` */ shouldNotHaveAttribute: (attribute: string) => Cypress.Chainable; /** * Assert that the first element of the selection has the given attribute, using `.prop()`. * Optionally, assert a particular value as well. The return value is available for chaining. * @example * ```ts * then(get.elementByTestId("selector")).shouldHaveProperty("test") * ``` */ shouldHaveProp: (property: string, expectedValue: string | boolean) => Cypress.Chainable; /** * Assert that an element has a css property with the given value. * @example * ```ts * then(get.elementByTestId("selector")).shouldHaveCss("color", "rgb(102, 102, 102)"") * ``` */ shouldHaveCss: (property: string, expectedValue: string) => Cypress.Chainable; /** * Assert spy was called at least once with the provided arguments. * @example * ```ts * then(get.spy("onSomething")).shouldHaveBeenCalledWith({ id: 1 }) * ``` */ shouldHaveBeenCalledWith: (...args: any[]) => Cypress.Chainable; /** Assert spy was called with matching arguments (and possibly others). * @example * ```ts * then(get.spy("onSomething")).shouldHaveBeenCalledWithMatch(match({ id: 1 })) * ``` * * @example * ```ts * it('should call the get method of the HTTP client with a URL with query param filter = status', () => { * healthService.fetchHealthResults(status); * then(get.mock.httpClientService().get).shouldHaveBeenCalledWith( * match(baseURL), * match.hasNested( * 'params.updates[0]', * match({ param: 'filter', value: `status eq ${status}` }) * ) * ); * }); * ``` */ shouldHaveBeenCalledWithMatch: (...args: any[]) => Cypress.Chainable; /** Asserts spy was called ate least once * @example * ```ts * then(get.spy("onSomething")).shouldHaveBeenCalled() * ``` */ shouldHaveBeenCalled: () => Cypress.Chainable; /** Asserts spy was called exactly once * @example * ```ts * then(get.spy("onSomething")).shouldHaveBeenCalledOnce() * ``` */ shouldHaveBeenCalledOnce: () => Cypress.Chainable; /** Asserts spy was called exactly twice * @example * ```ts * then(get.spy("onSomething")).shouldHaveBeenCalledTwice() * ``` */ shouldHaveBeenCalledTwice: () => Cypress.Chainable; /** Asserts spy was called exactly thrice * @example * ```ts * then(get.spy("onSomething")).shouldHaveBeenCalledThrice() * ``` */ shouldHaveBeenCalledThrice: () => Cypress.Chainable; /** Asserts spy was called exactly n times * @param n number of times spy should have been called * @example * ```ts * then(get.spy("onSomething")).shouldHaveBeenCalledTimes(5) * ``` */ shouldHaveBeenCalledTimes: (n: number) => Cypress.Chainable; /** Asserts spy was NOT called exactly n times * @param n number of times spy should NOT have been called * @example * ```ts * then(get.spy("onSomething")).shouldNotHaveBeenCalledTimes(5) * ``` */ shouldNotHaveBeenCalledTimes: (n: number) => Cypress.Chainable; /** * Asserts spy was not called * @example * ```ts * then(get.spy("onSomething")).shouldNotHaveBeenCalled() * ``` */ shouldNotHaveBeenCalled: () => Cypress.Chainable; /*** * When no arguments are provided, shouldThrow invokes the target function and asserts that no error is thrown. * When one argument is provided, and it's a string, shouldThrow invokes the target function and asserts that no error is thrown with a message that contains that string. * * @example * ```ts * function badFn() { console.log('Illegal salmon!') } * then(() => badFn()).shouldNotThrow() * then(() => badFn()).shouldNotThrow('salmon') * then(() => badFn()).shouldNotThrow(/salmon/) * ``` */ shouldNotThrow: (value?: string | RegExp | undefined) => Cypress.Chainable; /*** * When no arguments are provided, shouldThrow invokes the target function and asserts that an error is thrown. * When one argument is provided, and it's a string, shouldThrow invokes the target function and asserts that an error is thrown with a message that contains that string. * * @example * ```ts * function badFn() { throw new TypeError('Illegal salmon!') } * then(() => badFn()).shouldThrow() * then(() => badFn()).shouldThrow('salmon') * then(() => badFn()).shouldThrow(/salmon/) * ``` */ shouldThrow: (value?: string | RegExp | undefined) => Cypress.Chainable; } /** Wraps Cypress.Chainable and returns Assertable, decoupling test code form cypress 'should' assertions. * This way you can add assertions of your own, by extending Assertable class. * @example * ```ts * then(get.elementByTestId("selector")).shouldHaveLength(3) * ``` * @example * ```ts * import { Assertable, then } from "@shellygo/cypress-test-utils/assertable"; * * class MyAssertable extends Assertable { * private styleFromWindow = (win: Window) => { * const styleItem = win.localStorage.getItem(`style`); * const obj = JSON.parse(styleItem || ""); * return obj; * }; * public shouldEqualToStoredStyle = () => * then( * new CypressHelper().get.window().then((win) => { * const style = styleFromWindow(win); * then(this.chainable).shouldDeepNestedInclude(style); * }) * ); * } * * class Driver { * public given = { * // methods for setting test pre-conditions * }; * public when = { * // methods for test "actions", such as click, darg & drop, etc. * }; * public get = { * // getter, for exploring the outcome, such as getting a text color a span * }; * public then = (chainable: Cypress.Chainable) => new MyAssertable(chainable); * } * ``` */ export declare const then: (subject: Cypress.Chainable | any) => Assertable; export {};