I'm writing some simple tests for my React components using TestUtils and I'm finding that both the TestUtils.FindRenderedDOMComponentWithClass and TestUtils.FindRenderedDOMComponentWithTag methods are pretty limiting. I'd like to find a component using the typical CSS selector (i.e. tag.class [attr]) but it doesn't seem like this is an option.
Is there a simple way to find an element with a specific attribute? If not are there any useful tools for finding components apart from TestUtils?
React.TestUtilsdoes not offer component searches with CSS selectors so I went with a lightweight extension of the baseTestUtilsclass called react-testutils-addition. It offeres afind()method which parses the CSS selector style input and usesTestUtils.findAllInRenderedTreeto find the component.