Skip to content
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

JestMatchersShape<Matchers<void, HTMLElement>, Matchers<Promise<void>, HTMLElement>> doesn't has toBeVisible / toBeInDocument attributes #178

Closed
anyexinglu opened this issue Jan 4, 2020 · 7 comments

Comments

@anyexinglu
Copy link

anyexinglu commented Jan 4, 2020

  • @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

#11 (comment)

@anyexinglu
Copy link
Author

anyexinglu commented Jan 4, 2020

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.

@reinismu
Copy link

reinismu commented Mar 9, 2020

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

@gnapse
Copy link
Member

gnapse commented Mar 9, 2020

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

@ajdelossantos
Copy link

ajdelossantos commented Mar 11, 2020

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.

@loremaps
Copy link

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

@ChinPTeo
Copy link

ChinPTeo commented Jun 3, 2022

I had the same issue and fixed it by installing @types/testing-library__jest-dom, hope this helps someone

@zzswang
Copy link

zzswang commented Jun 25, 2022

I had the same issue and fixed it by installing @types/testing-library__jest-dom, hope this helps someone

I run into this issue too, just init the project with CRA.

And fixed it by add @types/testing-library__jest-dom package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants