testing-library / jest-dom

:owl: Custom jest matchers to test the state of the DOM

Home Page:https://testing-library.com/docs/ecosystem-jest-dom

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

It looks like the Recent Build has a Breaking Error in it OR that you need to update the usage

mickeypuri opened this issue · comments

I followed the exact instructions as in your readme, and using the latest version of the library,

  1. Created a setupTests.ts file, with the single line
    import "@testing-library/jest-dom"

  2. Made sure this file is referenced in the tsconfig.json, inside of the includes.
    "include": ["./setupTests.ts"],

  3. Also referenced it in the jest.config.js
    setupFilesAfterEnv: ["./setupTests.ts"]

Now when i run tests, they all pass,

but in the test file, I get a typescript error, that the type toBeVisible does not exist, but if I added a direct import of
@testing-library/jest-dom then typescript was happy.

THEN

I uninstalled the latest version of @testing-library/jest-dom and went to Version 5.16.5, from one year back and installed that. I made no other change and found that immediately the toBeVisible type was no longer throwing an error.

It seems therefore that sometime after Version 5.16.5, a bug has been introduced - OR that you need to update the usage as the old usage instructions are no longer valid.

Version 5.17.0 is fine too, it seems the issue is from Version 6 onwards, possibly the usage instructions need changing, or there is a breaking error.