-
Notifications
You must be signed in to change notification settings - Fork 470
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
getByTestId not working when upgrading @testing-library/dom from version 9.3.1 to 9.3.2 or above #1276
Comments
Try with import React from 'react';
import { render, screen } from '@testing-library/react';
test('FacetSize callback', async () => {
render(<div data-testid="123">Test</div>);
const testTestId = screen.getByTestId('123');
expect(testTestId).toBeInTheDocument();
});
REF: https://testing-library.com/docs/queries/bytestid/ If you make extensive use of |
Thanks @jlp-craigmorten, I believe that's the issue. @valleywood, if it's not the issue please re-open :) |
Thanks, is that a breaking change in 9.3.2 then? (since the same code works in 9.3.1) AFK right now but will test on monday 👍🏻 |
Nope, that's not related. You can see in the error message that your element uses |
@MatanBobi @jlp-craigmorten Thank you for helping out with this! Finally having some time to look into this a bit more. I'm using the configure method like this:
Removing this configuration and switching to all my test attributes to |
This might be related to multiple different |
That might have been the case! Think that you can close this issue again now since it probably was version related then. Thanks again for rapid support! 🙏
|
Hmm, actually, we might need to take a look into it or at least document it. I'm not sure based on this log why you have multiple version installed though, can you please explain? :) Looks like you have two version of |
Think that output of |
I don't know how related this is, but I'm using
stopped working. The only fix I could find was to import like this: |
This is probably related to the multiple versions of |
This is great news, thanks @MatanBobi. Could you please link to any relevant threads / issues that I could follow to stay up to date on that front? |
@janeklb Sure thing, here's the PR for that: |
Thank you! Are you aware of any initiatives to try and get other major libs (such as @storybook/test) to move DTL to a peer dep? |
@janeklb nope, but once we'll release the new version of RTL we can push the ecosystem to do the same :) |
Possibly also the reason for this issue:
findByRole doesn't find the role
@testing-library/dom
version: 9.3.2"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.1.0",
"@types/jest": "^29.5.8",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
Relevant code or config:
What you did:
Ran test according to above
What happened:
Getting this error:
Problem description:
Test fails when running with @testing-library/dom version higher than 9.3.1
Exact same code works with version 9.3.1 and below.
Suggested solution:
The text was updated successfully, but these errors were encountered: