This library re-exports everything from the DOM Testing Library
@testing-library/dom). See the
documentation to see what goodies you can
|The HTML element the component is mounted to.||baseElement|
|The root HTML element to which the container is appended to.||document.body|
|Queries to bind to the baseElement. See getQueriesForElement.||null|
|Used when the component has already been mounted and requires a rerender. Not needed for most people. The rerender function passed back to you does this already.||false|
|A parent component to wrap YourComponent.||null|
|The HTML element the component is mounted to.|
|The root HTML element to which the container is appended to.|
|Logs the baseElement using prettyDom.|
|Unmounts the component from the container.|
|Calls render again passing in the original arguments and sets hydrate to true.|
|Returns the innerHTML of the container.|
|Returns all query functions to be used on the baseElement. If you pass in |
Unmounts the component from the container and destroys the container.
📝 When you import anything from the library, this automatically runs after each
test. If you'd like to disable this then set
to true when running your tests.
Just a convenience export that points to preact/test-utils/act. All renders and
events being fired are wrapped in
act, so you don't really need this. It's
responsible for flushing all effects and rerenders after invoking it.
📝 If you'd love to learn more, checkout this explanation. Even though it's for React, it gives you an idea of why it's needed.
Passes it to the @testing-library/dom
fireEvent. It's also wrapped in
you don't need to worry about doing it.
📝 Keep in mind mainly when using
h / Preact.createElement that React uses a
Synthetic event system, and Preact uses the browser's native
for event handling. This means events like
onDblClick in Preact. The double click example will
give you an idea of how to test using those functions.