cypress icon indicating copy to clipboard operation
cypress copied to clipboard

Property 'focus' does not exist on type 'Assertion'.

Open steinybot opened this issue 3 years ago • 1 comments

Current behavior

expect(el).to.have.focus

Reports that focus is missing:

TS2339: Property 'focus' does not exist on type 'Assertion'.

Screen Shot 2022-09-21 at 8 23 57 AM

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

steinybot avatar Sep 20 '22 20:09 steinybot

Those type definitions seem really old. There are a few missing assertions from chai-jquery 2.1.0.

steinybot avatar Sep 20 '22 20:09 steinybot

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.

chrisbreiding avatar Sep 22 '22 13:09 chrisbreiding