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

Type for window.alert does not allow Sinon.stub #3451

Closed
bahmutov opened this issue Feb 13, 2019 · 1 comment
Closed

Type for window.alert does not allow Sinon.stub #3451

bahmutov opened this issue Feb 13, 2019 · 1 comment
Assignees

Comments

@bahmutov
Copy link
Contributor

@bahmutov bahmutov commented Feb 13, 2019

Noticed when linting using typescript@next plugin that this code is not allowed

Cypress.on('window:alert', () => { }) // ok
Cypress.on('window:alert', cy.spy()) // ok
Cypress.on('window:alert', cy.stub()) // error

example dtslint errors from the build https://circleci.com/gh/cypress-io/cypress/61570

Installing to /root/cypress/cli/node_modules/dtslint/typescript-installs/next...
Installed!

Error: /root/cypress/cli/types/tests/kitchen-sink.ts:49:12
ERROR: 49:12  expect  TypeScript@next compile error: 
Argument of type '"window:alert"' is not assignable to parameter of type '"test:after:run"'.
ERROR: 52:7   expect  TypeScript@next compile error: 
Argument of type '"window:alert"' is not assignable to parameter of type '"test:after:run"'.
ERROR: 56:7   expect  TypeScript@next compile error: 
Argument of type '"window:confirm"' is not assignable to parameter of type '"test:after:run"'.

Seems our type definition for action "window:alert" allows our function or Sinon spy. Should also "or Sinon stub"

(action: 'window:alert', fn: ((text: string) => void) | Agent<sinon.SinonSpy>): void
``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants