@@ -96,11 +96,10 @@ const AllTheProviders: FC = ({ children }) => {
96
96
97
97
const customRender = (
98
98
ui : ReactElement ,
99
- options ? : Omit <RenderOptions , ' queries ' >
99
+ options ? : Omit <RenderOptions , ' wrapper ' >
100
100
) => render (ui , { wrapper: AllTheProviders , ... options })
101
101
102
102
export * from ' @testing-library/react'
103
-
104
103
export { customRender as render }
105
104
```
106
105
@@ -194,7 +193,12 @@ passing a [`queries`](api.mdx#render-options) option.
194
193
If you want to add custom queries globally, you can do this by defining a custom
195
194
render method:
196
195
197
- ``` js title="test-utils.js"
196
+ <Tabs groupId = " test-utils" defaultValue = " jsx" values = { [ {label: ' Javascript' ,
197
+ value: ' jsx' }, {label: ' Typescript' , value: ' tsx' }, ]} >
198
+
199
+ <TabItem value = " jsx" >
200
+
201
+ ``` jsx title="test-utils.js"
198
202
// test-utils.js
199
203
import { render , queries } from ' @testing-library/react'
200
204
import * as customQueries from ' ./custom-queries'
@@ -209,6 +213,28 @@ export * from '@testing-library/react'
209
213
export { customRender as render }
210
214
```
211
215
216
+ </TabItem >
217
+
218
+ <TabItem value = " tsx" >
219
+
220
+ ``` tsx title="test-utils.ts"
221
+ // test-utils.ts
222
+ import { render , queries , RenderOptions } from ' @testing-library/react'
223
+ import * as customQueries from ' ./custom-queries'
224
+ import { ReactElement } from ' react'
225
+
226
+ const customRender = (
227
+ ui : ReactElement ,
228
+ options ? : Omit <RenderOptions , ' queries' >
229
+ ) => render (ui , { queries: { ... queries , ... customQueries }, ... options })
230
+
231
+ export * from ' @testing-library/react'
232
+ export { customRender as render }
233
+ ```
234
+
235
+ </TabItem >
236
+ </Tabs >
237
+
212
238
You can then use your custom queries as you would any other query:
213
239
214
240
``` js
0 commit comments