Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to cypress 9 #1

Open
Akta3d opened this issue Mar 16, 2022 · 0 comments
Open

Upgrade to cypress 9 #1

Akta3d opened this issue Mar 16, 2022 · 0 comments

Comments

@Akta3d
Copy link

Akta3d commented Mar 16, 2022

Good exemple, but not work with version 9 of cypress.

How can we update your exemple ?

cypress-command-definition.ts

export interface NxCypressCommandDefinition<T extends keyof Cypress.Chainable> {
    name: T;
    options?: Cypress.CommandOptions & {prevSubject: false};
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    fn: Cypress.CommandFn<T>;
}

register-commands.ts

import { NxCypressCommandDefinition } from "./cypress-command-definition";

export function registerCommands (
    availableCommands: NxCypressCommandDefinition<keyof Cypress.Chainable>[]
) {
    availableCommands.forEach(commandDefinition => {

        if(commandDefinition.options) {
            Cypress.Commands.add(commandDefinition.name, commandDefinition.options, commandDefinition.fn);
        } else {
            Cypress.Commands.add(commandDefinition.name, commandDefinition.fn);
        }
    });
}

get-el-command.ts

import { NxCypressCommandDefinition } from "./cypress-command-definition";

declare global {
  // eslint-disable-next-line @typescript-eslint/no-namespace
  namespace Cypress {
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    interface Chainable {
      getEl(identifier: string): Chainable<Element>;
    }
  }
}

export const getElCommand: NxCypressCommandDefinition<keyof Cypress.Chainable> = {
  name: 'getEl',
  fn: (identifier: string) => {
    return cy.get(`[data-test="${identifier}"]`);
  }
};

I have an error on the fn definition in the getElCommand

Do you have an idea to solve it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant