ReactThreeTestInstance
- Properties
- Methods
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
.
testInstance.instance
Returns the instance object of the specific testInstance. This will be the THREE
initialized class.
testInstance.type
Returns the THREE
type of the test instance, e.g Scene
or Mesh
.
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.
testInstance.parent
Returns the parent testInstance of this testInstance. If no parent is available, it will return null
.
testInstance.children
Returns the children test instances of this test instance according to the property children
, this will not include Geometries, Materials etc.
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.
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.
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.
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.
testInstance.findAllByType(type)
Finds all test instances with the provided type. If no test instances are found, it will return an empty array.
testInstance.findByProps(props)
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.
testInstance.findAllByProps(props)
Finds all test instances with the provided props. If no test instances are found, it will return an empty array.