Jest-dom: JestMatchersShape<Matchers<void, HTMLElement>, Matchers<Promise<void>, HTMLElement>> doesn't has toBeVisible / toBeInDocument attributes

Created on 4 Jan 2020  ·  5Comments  ·  Source: testing-library/jest-dom

  • @testing-library/jest-dom version: 4.2.4
  • node version: 10.16.0
  • npm (or yarn) version: yarn v1.19.1

Relevant code or config:

// menu.test.tsx
expect(getByText('Option 5')).toBeVisible()

// scripts/expect.ts
import '@testing-library/jest-dom/extend-expect'

// jest.config.ts
setupFilesAfterEnv: ['<rootDir>/scripts/expect.ts']

What you did:

I configure the @testing-library/jest-dom/extend-expect following README.md Usage - 1

What happened:

The typescript definition doesn't work:

类型“JestMatchersShape<Matchers<void, HTMLElement>, Matchers<Promise<void>, HTMLElement>>”上不存在属性“toBeVisible”。ts(2339)

image

In English, the error means JestMatchersShape<Matchers<void, HTMLElement>, Matchers<Promise<void>, HTMLElement>> doesn't has toBeVisible / toBeInDocument attributes

Related issue:

It seems pointed out before, but the solution doesn't work

https://github.com/testing-library/jest-dom/pull/11#issuecomment-387817459

Most helpful comment

I've run into this issue with vscode and running tests in watch mode. After doing a --clearCache everything works.

All 5 comments

Sorry I can't reproduce the error a moment later.

It looks so strange, I tried reloading vscode window, restarting vscode and waited for a long time, the error always there...

So I went to do other things, then suddenly found the error disappeared and the definition shown.

image

So it works fine now, although I have done nothing to fix it.


I should close the issue now.

I have a similar error while running tests and using vscode.

I have noticed that based on some.test.ts size it works or doesn't work. This is so annoying and I can't seem to understand where this behavior is coming from

@reinismu we'd need a sample repo where this can be reproduced.

I've actually run into this same problem in my code. Jest will run the tests properly after a fresh reboot; when I revise the .spec file and save, I then get this error.

I'll have to create a sample repo to try and reproduce this.

I've run into this issue with vscode and running tests in watch mode. After doing a --clearCache everything works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gnapse picture gnapse  ·  3Comments

gnapse picture gnapse  ·  3Comments

lukaszfiszer picture lukaszfiszer  ·  6Comments

hiwelo picture hiwelo  ·  7Comments

jsphstls picture jsphstls  ·  4Comments