-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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: remove unnecessary eventemitter2 type definitions from cy, Cypress #21286
Changes from 2 commits
bff96a4
1bbdb51
e166028
e7ae31b
e9594b4
498dcde
d8d3f5d
458994b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,3 +87,17 @@ namespace CypressActionCommandOptionTests { | |
cy.get('el').click({scrollBehavior: false}) | ||
cy.get('el').click({scrollBehavior: true}) // $ExpectError | ||
} | ||
|
||
namespace CyEventEmitterTests { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we put a comment here (or alongside the types themselves) explaining why we'd expect errors for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wrote the reason like below: // `waitFor` doesn't exist in Node EventEmitter
// and it confuses the users with `cy.wait` |
||
cy.waitFor() // $ExpectError | ||
cy.prependListener() // $ExpectError | ||
cy.on('random', () => {}) | ||
cy.removeAllListeners() | ||
cy.removeListener('a', () => {}) | ||
|
||
Cypress.waitFor() // $ExpectError | ||
Cypress.prependListener() // $ExpectError | ||
Cypress.on('random', () => {}) | ||
Cypress.removeAllListeners() | ||
Cypress.removeListener('a', () => {}) | ||
} |
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.
Our docs say that Cypress/cy are "standard Node event emitters": https://docs.cypress.io/api/events/catalog-of-events#Binding-to-Events
I'm wondering if we need to either:
addListener
. The other missing APIs are probably less frequently used, but it's hard to say.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 decided to change the type to
Omit<EventEmitter2, 'waitFor'>
.Because other functions are harmless, they're really unlikely to be used in the real world cases, though.
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.
Nice 👍