DEV Community

Discussion on: What do you think of React Testing Library?

Collapse
 
2ezpz2plzme profile image
Steven Liao

RTL doesn't prevent you from accessing the instance since it's still possible to get the instance by

const ref = React.createRef();
const testUtils = render(<ClassComponent ref={ref} />;
const instance = ref.current;

The fact that RTL does not provide an instance() API certainly does discourage accessing the instance though, and I agree with that. I also agree with all your parts.

Collapse
 
shaik_ameem profile image
Ameem Shaik

True, "prevent" was probably the wrong word to use here!

Thread Thread
 
kentcdodds profile image
Kent C. Dodds

I use the word "enable"