bahmutov / cypress-cdp

A custom Cypress command to wrap the remote debugger protocol low level command
https://glebbahmutov.com/blog/when-can-the-test-click/
16 stars 1 forks source link

The `log` option's types are mismatched #99

Open adamalston opened 4 months ago

adamalston commented 4 months ago

Per the code, log can be set to a boolean value in the CDP command:

https://github.com/bahmutov/cypress-cdp/blob/3cbd2061cadd2d2764f999d3e238fb1c21c25e0f/src/index.js#L21

However, LogConfig is not a boolean type:

https://github.com/bahmutov/cypress-cdp/blob/3cbd2061cadd2d2764f999d3e238fb1c21c25e0f/src/index.d.ts#L28

Cypress LogConfig type:

https://github.com/cypress-io/cypress/blob/1aad7ba7d1b28d2ea920cdc65a54af74ad470643/cli/types/cypress.d.ts#L6447-#L6466

Capocaccia commented 3 months ago

Agreed. As a result it makes it really difficult to use the hasEventListeners function with a type object provided.

joemaffei commented 2 months ago

The README shows that it's possible to use an object with just the type property set: https://github.com/bahmutov/cypress-cdp/blob/main/README.md?plain=1#L78

For now, this is my workaround:

cy.hasEventListeners('form',  {
  type: 'submit',
  // @ts-ignore https://github.com/bahmutov/cypress-cdp/issues/99
  log: false,
});
MattWeinstein commented 2 months ago

Since merging this PR, log has been made optional which partially resolves this issue.

Capocaccia commented 2 months ago

Agreed @MattWeinstein.