Skip to content
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

@testing-library/cypress causes non-cypress tests to fail #252

Open
OVO-Josh opened this issue Jan 27, 2023 · 1 comment
Open

@testing-library/cypress causes non-cypress tests to fail #252

OVO-Josh opened this issue Jan 27, 2023 · 1 comment

Comments

@OVO-Josh
Copy link

  • cypress-testing-library version: 9.0.0 (but also tested back to 6.0.7)
  • node version: 18.9.0
  • npm (or yarn) version: yarn v1.22.19

Relevant code or config

What you did:

After installing @testing-library/cypress, multiple unit tests written in @testing-library/react started to break.

What happened:

Prior to installing, the following unit test worked:

test("Add buy request and remove buy request buttons work", async () => {
  const user = userEvent.setup();
  render(<NewTradePage />);
  await user.click(screen.getAllByText("Add Buy Request")[0]);
  expect(screen.getByText("Requested Buy Volume 2")).toBeInTheDocument();
  await user.click(screen.getAllByText("Remove Buy Request")[0]);
  expect(screen.queryByText(/Requested Buy Volume 2 (MWh)/)).toBeNull();
});

After installing, I get the following error

TestingLibraryElementError: Unable to find an element with the text: Requested Buy Volume 2.

Suggested Solution:

I'm guessing this is due to @testing-library/react requiring version 8.5 of @testing-library/dom, whereas @testing-library/cypress requires version 8.1 - so maybe bumping the dependencies of the library?

@AlbericTrancart
Copy link

AlbericTrancart commented Apr 5, 2023

Bumping this issue, we cannot use this lib as a lot of our React / Jest tests are breaking if we try to install it. (we use RTL v14.0.0)

=> Found "@testing-library/[email protected]"
info Reasons this module exists
   - "@testing-library#cypress" depends on it
   - Hoisted from "@testing-library#cypress#@testing-library#dom"
info Disk size without dependencies: "3.84MB"
info Disk size with unique dependencies: "6.65MB"
info Disk size with transitive dependencies: "7.18MB"
info Number of shared dependencies: 19
=> Found "@testing-library/react#@testing-library/[email protected]"
info This module exists because "@testing-library#react" depends on it.
info Disk size without dependencies: "2.96MB"
info Disk size with unique dependencies: "5.77MB"
info Disk size with transitive dependencies: "6.3MB"
info Number of shared dependencies: 19
Done in 0.98s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants