Skip to content

Commit e6ac5ad

Browse files
committed
pass options to renderer; add update & unmount, rm instance & renderer
1 parent 520355a commit e6ac5ad

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Diff for: src/index.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@ export const flushMicrotasksQueue = (): Promise<any> =>
2626
* Renders test component deeply using react-test-renderer and exposes helpers
2727
* to assert on the output.
2828
*/
29-
export const render = (component: React.Element<*>) => {
30-
const renderer = TestRenderer.create(component);
29+
export const render = (
30+
component: React.Element<*>,
31+
options?: { createNodeMock: (element: React.Element<*>) => any }
32+
) => {
33+
const renderer = TestRenderer.create(component, options);
3134
const instance = renderer.root;
3235

3336
return {
34-
instance,
35-
renderer,
3637
getByTestId: (testID: string) => instance.findByProps({ testID }),
37-
getByName: (name: string) =>
38+
getByName: (name: string | React.Element<*>) =>
3839
instance.find(node => getNodeByName(node, name)),
39-
getAllByName: (name: string) =>
40+
getAllByName: (name: string | React.Element<*>) =>
4041
instance.findAll(node => getNodeByName(node, name)),
4142
getByText: (text: string | RegExp) =>
4243
instance.find(node => getNodeByText(node, text)),
@@ -46,6 +47,8 @@ export const render = (component: React.Element<*>) => {
4647
instance.findByProps(props),
4748
getAllByProps: (props: { [propName: string]: any }) =>
4849
instance.findAllByProps(props),
50+
update: renderer.update,
51+
unmount: renderer.unmount,
4952
};
5053
};
5154

0 commit comments

Comments
 (0)