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
fix: include event emitter types from cypress types #14992
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ Flakiness
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
@@ -1,4 +1,5 @@ | |||
/// <reference path="./cypress-npm-api.d.ts" /> | |||
/// <reference path="./cypress-eventemitter.d.ts" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we are using NodeEventEmitter type here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I became curious that on
really returns Cypress
. So, I tested with the code below:
it('t', () => {
console.log(Cypress
.on('test:before:run', () => {
console.log('before running a test')
}).version)
})
And it returned 6.4.0
correctly.
In #14991, const cy: Cypress.cy & EventEmitter
was mentioned but not covered in this PR.
I tried extending EventEmitter
on Cypress.cy
definition like interface cy extends Chainable<undefined>, EventEmitter {}
but failed because of the clash in property types. It's an open issue since 2017.
Maybe, the easiest solution for this would be adding type cy = Cypress.cy & EventEmitter
above cy
definition and set the type with it.
Internal Jira issue: TR-668 |
Yup @sainthkh it returns
I tried |
Also, I do find it funny that you can combine clashing types when declaring a variable like |
I will split #14991 to have the type merge in a separate issue |
User facing changelog
Types no longer complain when you chain event listeners like
Additional details
Notice the types returned
void
while the test happily runs. Also moved the emitter reference line into the file where it was used.How has the user experience changed?
No more type errors
PR Tasks