Test Drive React
Opinionated library for Test-Driven Development of React components, extending
Test Drive and providing its
timing functions,
DOM parts lookup,
presence/absence matchers and
layout matchers.
In addition, it reexports React simulate
testing utility and integrated renderer
ClientRenderer
ClientRenderer
provides a utility for rendering React components in consistent
and convenient way. It creates the holding container, if necessary, with uniform positioning,
automatically binds to it all important Test Drive helper functions, and proivides clean-up
mechanism.
For a typical use, see the end-to-end test.
The renderer is created simply by invoking new ClientRenderer()
.
render(element, container?)
Renders the element
React component. If container
is not specified, a new one is created.
Returns RenderingContext
with following fields:
container
result
- rendered root component (either DOM Element or React component instance)select
- DOM selector
pre-bound to the containerwaitForDom
- DOM timing function
pre-bound to the container
cleanup()
Unmounts the root component and removes any container that had been created by the renderer.