• 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.

    Parameters

    • subject: any

    Returns Assertable<unknown>

    Example

    then(get.elementByTestId("selector")).shouldHaveLength(3)
    

    Example

    import { Assertable, then } from "@shellygo/cypress-test-utils/assertable";

    class MyAssertable<T> extends Assertable<T> {
    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 = {
    .
    .
    };
    public when = {
    .
    .
    };
    public get = {
    .
    .
    };
    public then = (chainable: Cypress.Chainable<any>) => new MyAssertable(chainable);
    }

Generated using TypeDoc