I have a Create React App project that uses React Testing Library for testing, and has some fairly large legacy class components. These components have methods on them to accomplish various tasks (sometimes not directly related to rendering); they need to compute various functions of moderate complexity based on data structures in the component's React state.
I see these different component class methods as "units" that are worth having tests for in their own right. But React Testing Library's developers seem to want to stop me from testing these component class methods. Based on this question, the Testing Library Guiding Principles, and what they say about not providing a migration path for Enzyme tests for component class methods, I'm not supposed to be able to use Testing Library to unit test a method on a React class component because the Testing Library developers say that is not part of the component's contract and should not be part of a test for that component.
If I am a component author and I am writing a component, and I want to organize the work of my component beyond a single monolithic JavaScript function, how am I meant to test those individual pieces or sub-units under React Testing Library?
The migration guide seems to boil down to "test the component as a whole". But if I test the component as a whole and it doesn't work, how do I eliminate possibilities and say, for example, "I know the binary search logic works, but there is a bug in the logic that translates between the data structures used in the props and those used in the state"?
propsbut needs it represented differently instate, I should create a new piece of my application not logically part of that component that does that translation, and I should write tests for that piece. So a component with a lot of machinery to let it do what it does it might have several auxiliary code files next to it for widgets that it needs, each with their own tests? And then the "component" is just view and glue code.