Our project has both enzyme
and testing-library
.
My goal is to overwrite getByTestId to my custom.
But when I'm adding the second configuration to my setup.test.js - some tests become failing with Found multiple elements with the text
.
setup.test.js:
const { configure } = require("enzyme");
const Adapter = require("enzyme-adapter-react-16");
import { configure as conf } from "@testing-library/react";
window.__config = {};
conf({ testIdAttribute: "data-my-test-id" });
configure({ adapter: new Adapter() });
My versions:
"enzyme": "^3.11.0",
"@testing-library/react": "^11.0.4",
This is happening because expected cleanup doesn't work. Move below configuration to a new file, let's say "env-setup.js"
Now, in jest.config.js: