Skip to content

Latest commit

 

History

History
121 lines (80 loc) · 3.7 KB

rttr-instance.md

File metadata and controls

121 lines (80 loc) · 3.7 KB

React Three Test Instance API

Table of Contents


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

testInstance.instance

Returns the instance object of the specific testInstance. This will be the THREE initialized class.

type

testInstance.type

Returns the THREE type of the test instance, e.g Scene or Mesh.

props

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

testInstance.parent

Returns the parent testInstance of this testInstance. If no parent is available, it will return null.

children

testInstance.children

Returns the children test instances of this test instance according to the property children, this will not include Geometries, Materials etc.

allChildren

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()

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()

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()

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()

testInstance.findAllByType(type)

Finds all test instances with the provided type. If no test instances are found, it will return an empty array.

findByProps()

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.

findAllByProps()

testInstance.findAllByProps(props)

Finds all test instances with the provided props. If no test instances are found, it will return an empty array.