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

Test component with react testing-library #65

Open
christianpredebon opened this issue Feb 28, 2023 · 0 comments
Open

Test component with react testing-library #65

christianpredebon opened this issue Feb 28, 2023 · 0 comments

Comments

@christianpredebon
Copy link

Hi,
I'm trying to test the component with the react testing-library. The test is quite simple but for some reason when I run it the testid cannot be found. The error returned is TestingLibraryElementError: Unable to find an element by: [data-testid="clamped-text"] and the test example is as follow:

const longText = "...";

it("should clamp text", () => {
  render(<ClampLines {...props} data-testid="clamped-text" />);

  const containerDiv = screen.getByTestId("clamped-text");
  expect(containerDiv).toBeInTheDocument();
});

When I go to analyse the elements in the browser, the element with that testid actually does not exist. Any help?

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

1 participant