packages/test-renderer/markdown/rttr-instance.md
ReactThreeTestInstance
ReactThreeTestInstance ⚛️This is an internal class that wraps the elements returned from ReactThreeTestRenderer.create. It has several properties & methods to enhance the testing experience. Similar to the core API, it closely mirrors the API of react-test-renderer.
instance <a id="instance-prop-instance"></a>testInstance.instance
Returns the instance object of the specific testInstance. This will be the THREE initialized class.
type <a id="instance-prop-type"></a>testInstance.type
Returns the THREE type of the test instance, e.g Scene or Mesh.
props <a id="instance-prop-props"></a>testInstance.props
Returns an object of the props that are currently being passed to the element. This will include hidden ones such as attach="geometry" which are automatically applied in the reconciler.
parent <a id="instance-prop-parent"></a>testInstance.parent
Returns the parent testInstance of this testInstance. If no parent is available, it will return null.
children <a id="instance-prop-children"></a>testInstance.children
Returns the children test instances of this test instance according to the property children, this will not include Geometries, Materials etc.
allChildren <a id="instance-prop-allChildren"></a>testInstance.allChildren
Returns all the children testInstances of this test instance, this will be as thorough as testRenderer.toTree() capturing all react components in the tree.
find() <a id="instance-meth-find"></a>testInstance.find(test)
Find a single test instance for which test(testInstance) returns true. If test(testInstance) does not return true for exactly one test instance it will throw an error.
findAll() <a id="instance-meth-findall"></a>testInstance.findAll(test)
Finds all test instances for which test(testInstance) returns true. If no test instances are found, it will return an empty array.
findByType() <a id="instance-meth-findbytype"></a>testInstance.findByType(type)
Find a single test instance with the provided type. If there is not exactly one test instance with the provided type it will throw an error.
findAllByType() <a id="instance-meth-findallbytype"></a>testInstance.findAllByType(type)
Finds all test instances with the provided type. If no test instances are found, it will return an empty array.
findByProps() <a id="instance-meth-findbyprops"></a>testInstance.findByProps(props)
// Also accepts RegExp matchers
testInstance.findByProps({ [prop]: /^match/i })
Find a single test instance with the provided props. If there is not exactly one test instance with the provided props it will throw an error.
findAllByProps() <a id="instance-meth-findallbyprops"></a>testInstance.findAllByProps(props)
// Also accepts RegExp matchers
testInstance.findAllByProps({ [prop]: /^matches/i })
Finds all test instances with the provided props. If no test instances are found, it will return an empty array.