cypress
cypress copied to clipboard
Property 'focus' does not exist on type 'Assertion'.
Current behavior
expect(el).to.have.focus
Reports that focus is missing:
TS2339: Property 'focus' does not exist on type 'Assertion'.
And yes I have:
"typeRoots": [
"cypress/types"
]
We can see in cypress/types/chai-jquery/index.d.ts is using:
// Type definitions for chai-jquery 1.1.1
The assertion does exist (https://github.com/cypress-io/cypress/issues/97) although it is using is(':focus') rather than === document.activeElement like the chai-jquery docs say (https://www.chaijs.com/plugins/chai-jquery/#focus).
Desired behavior
Include all the available chai-jquery properties in the Typescript definitions.
Test code to reproduce
https://github.com/steinybot/bug-reports/tree/cypress/chai-jquery-focus
Cypress Version
10.8.0
Node version
18.5.0
Operating System
macOS 12.6
Debug Logs
No response
Other
No response
Those type definitions seem really old. There are a few missing assertions from chai-jquery 2.1.0.
Looks like the types could use an update. I'll route this to a team to fix, though we'd also be happy to accept a PR to fix it as well.