New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
renderHook does not work with React Magnetic DI wrapper #917
Labels
bug
Something isn't working
Comments
@haskellcamargo Your code contains a mistake: const renderHookWithDi = <TProps, TResult>(
callback: (props: TProps) => TResult,
dependencies: Dependency[] = [],
) =>
// The generics of renderHook were switched, this is the correct way:
renderHook<TResult, TProps>(callback, {
// No type assertion needed anymore
wrapper: createRtlDiWrapper(dependencies),
});
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
react-hooks-testing-library
version:8.0.1
react
version:16.13.1
react-dom
version:16.13.1
React Magnetic DI is a library that allows dependency injection in React components and functions for testing purposes.
It looks like the wrappers for
renderHook
andrender
(from@testing-library/react
) behave quite differently. Whilerender
works with custom providers other than the React context, somehowrenderHook
fails to do so.renderHook
does not work when a React Magnetic DI provider is used as a wrapper.Reproducible example
Expectation
Both tests would pass as the dependency should be properly injected using the DI wrapper.
Actual Behaviour
Only the second test, using
render
, passes, as the dependency is properly injected. The first one fails because it uses the actual implementation instead.The text was updated successfully, but these errors were encountered: