-
Notifications
You must be signed in to change notification settings - Fork 393
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
Property 'toBeChecked' does not exist on type 'Matchers<void, Element>' #442
Comments
|
@gnapse IDK whether it's related, but I face a similar issue. I created a demo repo here. |
|
How come this is needed? |
Two things fixed my issue:
Note: either of those solutions worked on their own. I did not need to combine them. @gnapse I also got this error when using the
|
As a follow up to my previous comment, this package is very unstable when using jest-cucumber. Neither of the solutions I previously posted work to allow the matchers to be found consistently. There appears to be some sort of race condition as the matchers are sometimes found. Hopefully this information helps as it would be great to use these matchers, but as it stands this package is unusable in my project. |
I have same error. error TS2339: Property 'toBeInTheDocument' does not exist on type 'Matchers<void, HTMLElement> & SnapshotMatchers<void, HTMLElement> & Inverse<JestMatchers<void, HTMLElement>> & PromiseMatchers<...>'.
tsconfig.json
jest.config.js
jest-setup.ts
|
I am also getting similar errors. Have tried pretty much all the things mentioned above. I am using Next JS. So far I've:
But nothing so far is getting rid of the errors. The tests all work fine, so for now I have found the easiest solution for now is just to add Here is what a typical test looks like:
and here are my error messages: If anyone has any tips on the right way to go about fixing this I would appreciate it. I am still new at typescript but lately it fells lik > 50% of my time is spent googling solutions to type errors like this.... LINK TO REPO: https://github.com/PaulHaze/ott-testing |
Hi there! I've got the same problem
|
Same issue |
This one should be the solution: pnpm/pnpm#4920 (comment) |
For me, the problem got resolved with Setup now is:
|
It appears like i were experiencing some problems with YARN version 3, but were able to resolve it by downgrading to YARN version 1. It's worth mentioning that this issue only occurred in my (CI). |
If you are using pnpm this might work for you. |
Thanks you. It works for me. |
I've fixed it including in the jest-setup.ts also the react package and |
I fixed this by installing eslint-plugin-jest and adding the extension to my |
@ptz000's comment is what worked for me. I tried the others with no luck. Updating the {
"compilerOptions": {
"typeRoots": ["./node_modules/@types"]
}
}
|
I do not know how this works, but I have a file types/window.ts and in that I put this in there, and it works. window.ts exports:
|
It Also works using versions: "@testing-library/angular": "^14.3.0" setup-jest.ts:
tsconfig.json:
in the first time I tried this configuration it doesn't worked, but, I added import |
Same problem here. Using npm 9.6.7 and node 18.17.1 |
For anyone having this issue after an upgrade from v5 -> v6, the test environment set-up where It makes more sense but the documentation needs to be updated to reflect this change. https://github.com/testing-library/jest-dom/blob/v5.17.0/src/extend-expect.js |
For me I tried adding the following imports to my jest setup file, didnot work
Even adding "@types/testing-library__jest-dom" to types in tsconfig didnot help. But just importing the following in a single test file
fixes it in all test files. |
I tried adding
|
For me, explicitly adding the |
This worked for me 🎉 🙏 |
None of the tips above helped me in 2024. This below ended up working: Updating |
I have tried different things but then noticed that it was written with uppercase letter: "ToBeChecked()". It was resolved for me by writing with lowercase letter "toBeChecked()". |
To avoid complaint about > Property 'toBeChecked' does not exist on type 'Matchers<void, Element>' See testing-library/jest-dom#442 (comment) and https://github.com/testing-library/jest-dom/releases/tag/v6.2.0
@testing-library/jest-dom
version: 5.16.2node
version: v14.17.4npm
(oryarn
) version: 6.14.14dom-testing-library
version: (if applicable)react-testing-library
version: 12.1.3Relevant code or config:
What you did:
Trying to test if an input is checked
What happened:
Typescript shows the error
Property 'toBeChecked' does not exist on type 'Matchers<void, Element>'
although the test runs correctly.What I have tried:
import "jest-dom/extend-expect";
and `import '@testing-library/jest-dom/extend-expect'; as recommended here["jest-styled-components", "@types/testing-library__jest-dom"]
to the types intsconfig
import '@testing-library/jest-dom/extend-expect';
tosrc/setupTests.ts
document.querySelector('input')
withdocument.querySelector('input')!
ordocument.querySelector('input') as HTMLInputElement
No matter what I do, I always get the same or a similar issue
The text was updated successfully, but these errors were encountered: