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

Typescript compatibility #13

Open
ashblox opened this issue Jan 5, 2022 · 2 comments
Open

Typescript compatibility #13

ashblox opened this issue Jan 5, 2022 · 2 comments

Comments

@ashblox
Copy link

ashblox commented Jan 5, 2022

Maybe I'm missing something in my configuration, but I followed the README (added an import statement to my cypress/support/index.js file), and then for good measure added "cypress-plugin-signalr" to the types property in my tsconfig file.

I still seem to be having trouble though with Cypress recognizing the custom commands or the global variable signalrMock.

I've put together an example repo here. If you could take a look and please advise, I'd greatly appreciate it!

@ninjabadgerpirate
Copy link

ninjabadgerpirate commented Jan 11, 2022

I am also having issues with TypeScript when I add the following plugin code to support/commands.ts file:

Cypress.Commands.overwrite('visit', (originalFn, url) => {
  return originalFn(url, {
    onBeforeLoad(window) {
      window.signalrMock = signalrMock;
    },
  });
});

When I do this I see the following error:

Argument of type '{ onBeforeLoad(window: any): void; }' is not assignable to parameter of type 'string'
Cannot find name 'signalrMock'

I have added the following import statement to the support/index.ts file as recommended:

import 'cypress-plugin-signalr';

But the errors remain. After changing the code to the following the errors disappear:

declare var signalrMock: any;

Cypress.Commands.overwrite('visit', (originalFn: any, url:string) => {
  return originalFn(url, {
    onBeforeLoad(window) {
      window.signalrMock = signalrMock;
    },
  });
});

Can you advise if this is the right approach?

@basslagter
Copy link
Owner

I am not actively maintaining this package anymore but if you like you can make a PR

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

3 participants