-
Notifications
You must be signed in to change notification settings - Fork 729
How to get the elements after rerender #1290
Unanswered
19Qingfeng
asked this question in
Q&A
-
I have reviewed the documentation, but still haven't found how to obtain the re rendered elements, eg:
const ref = createRef<TabInstance>(); const { rerender,getByRole } = render(<TabComponent headerRef={ref} />); const input = getByRole('textbox') expect(ref.current).toBeDefined(); rerender(<TabComponent headerRef={ref} value="3" />) // May I ask how to obtain the rendered `const input = getByRole('textbox')` element
I'm not sure how I should obtain it, I haven't found any valid information on the document
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
Hi @19Qingfeng.
I'm not sure I'm following the purpose of this test.
Using ref
inside a test isn't a best practice since when we're testing we should act as if we're the user using our app.
If you want to test this component, I'd assert on what the user is actually seeing, if the value
3 is presented, I'd assert that.
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment