Since it is recommended to use screen rather than getById in react testing library, I'm changing all the instances of it to screen query selectors. However, there's a certain condition I'm not able to change.
const newComponent = render(
<AppContext.Provider value={newState}>
<App />
<AppContext.Provider>,
)
const id = queryByAttribute.bind(null,'id')
const result= getById(newComponent.container,'student-details')
expect(result.textContent).toBe('Suga')
I used the Testing playground and it suggested to use getByText, but if I do screen.getByText(/Suga/i), it fails because it considers the screen that rendered initially and not the new component to which I provide different state. How can I achieve this conversion?
Note: In the App.js file, the student-detail is a div with id and className.