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

Comments

2 participants
@bahmutov
Copy link
Collaborator

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
``
@cypress-bot

This comment has been minimized.

Copy link

cypress-bot bot commented Mar 15, 2019

Released in 3.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.