MCPcopy
hub / github.com/testing-library/react-hooks-testing-library / getRenderer

Function getRenderer

src/pure.ts:17–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15}
16
17function getRenderer() {
18 const validRenderer = renderers.find(({ required }) => hasDependency(required))
19
20 if (validRenderer) {
21 // eslint-disable-next-line @typescript-eslint/no-var-requires
22 return require(validRenderer.renderer) as ReactHooksRenderer
23 } else {
24 const options = renderers
25 .map(({ required }) => ` - ${required}`)
26 .sort((a, b) => a.localeCompare(b))
27 .join('\n')
28
29 throw new Error(
30 `Could not auto-detect a React renderer. Are you sure you've installed one of the following\n${options}\nIf you are using a bundler, please update your imports to use a specific renderer.\nFor instructions see: https://react-hooks-testing-library.com/installation#being-specific`
31 )
32 }
33}
34
35const { renderHook, act, cleanup, addCleanup, removeCleanup, suppressErrorOutput } = getRenderer()
36

Callers 3

pure.tsFile · 0.85
runForRenderers.tsFile · 0.85

Calls 1

hasDependencyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…