@testing-library/react version:"10.0.4""jest": "26.0.1""@testing-library/jest-dom": "5.7.0"Using with jest with a setup file having just import { configure } from "@testing-library/react"; with simple component
testing a component by using getByTestId
In the second test, getting the error Found multiple elements by: [data-testid="myinputtest"]
but when I un-comment import statement from the config file, it is passing.

Codesandbox url: https://codesandbox.io/s/rtl-test-c8hj6
It is not failing in codesandbox but can reproduce by exporting as zip and trying in local
Cleanup is not happening, can't select by using data-testid
Hi @krajasekhar,
Here's the fix (in the jest config of package.json):
"setupFiles": [
"react-app-polyfill/jsdom"
],
"setupFilesAfterEnv": [
"<rootDir>/config/jest/testingLibraryConfig.js"
],
Move the config to the setupFilesAfterEnv config because we require the jest environment to be setup to get the auto-cleanup functionality working.
Good luck!
Most helpful comment
Hi @krajasekhar,
Here's the fix (in the jest config of package.json):
Move the config to the
setupFilesAfterEnvconfig because we require the jest environment to be setup to get the auto-cleanup functionality working.Good luck!