@@ -98,20 +98,47 @@ export function render(
98
98
options ?: Omit < RenderOptions , 'queries' > ,
99
99
) : RenderResult
100
100
101
- // TODO JSDOC
102
101
interface RenderHookResult < Result , Props > {
102
+ /**
103
+ * Triggers a re-render. The props will be passed to your renderHook callback.
104
+ */
103
105
rerender : ( props ?: Props ) => void
104
- result : { current : Result }
106
+ /**
107
+ * This is a stable reference to the latest value returned by your renderHook
108
+ * callback
109
+ */
110
+ result : {
111
+ /**
112
+ * The value returned by your renderHook callback
113
+ */
114
+ current : Result
115
+ }
116
+ /**
117
+ * Unmounts the test component. This is useful for when you need to test
118
+ * any cleanup your useEffects have.
119
+ */
105
120
unmount : ( ) => void
106
121
}
107
122
108
- // TODO JSDOC
109
123
interface RenderHookOptions < Props > {
124
+ /**
125
+ * The argument passed to the renderHook callback. Can be useful if you plan
126
+ * to use the rerender utility to change the values passed to your hook.
127
+ */
110
128
initialProps ?: Props
111
- wrapper ?: React . ComponentType
129
+ /**
130
+ * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating
131
+ * reusable custom render functions for common data providers. See setup for examples.
132
+ *
133
+ * @see https://testing-library.com/docs/react-testing-library/api/#wrapper
134
+ */
135
+ wrapper ?: React . JSXElementConstructor < { children : React . ReactElement } >
112
136
}
113
137
114
- // TODO JSDOC
138
+ /**
139
+ * Allows you to render a hook within a test React component without having to
140
+ * create that component yourself.
141
+ */
115
142
export function renderHook < Result , Props > (
116
143
render : ( initialProps : Props ) => Result ,
117
144
options ?: RenderHookOptions < Props > ,
0 commit comments