Skip to content

Cannot use @​testing-library/jest-dom directly in setupFilesAfterEnv #517

@hugo

Description

@hugo
  • @testing-library/jest-dom version: 6.0.1
  • node version: 18.13.0
  • npm (or yarn) version: 9.8.1

Relevant code or config:

{
  setupFilesAfterEnv: ['@testing-library/jest-dom'],
}

What you did:

Upgrade from 5.17.0 to 6.0.1.
Ran jest

What happened:

An error was reported:

Property 'toBeInTheDocument' does not exist on type 'JestMatchers'.

Reproduction:

I could not make this work in CodeSandbox, but here is a reproduction repo.

Problem description:

Previously directly referencing '@​testing-library/jest-dom' in the setupFilesAfterEnv list worked just fine. After 6.0.0 it is necessary to create a separate file that has the import '@​testing-library/jest-dom' line in it.

Suggested solution:

Sorry, I don't know enough about how these mechanisms work to suggest a fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions