Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottcorgan/4580ff7109ca1557b8955ab8d4bd6ec3 to your computer and use it in GitHub Desktop.
Save scottcorgan/4580ff7109ca1557b8955ab8d4bd6ec3 to your computer and use it in GitHub Desktop.
Testing hooks with Remix and Testing Library
/**
* If have any hooks that use Remix hooks, this helper will save you headaches
*/
import { createRemixStub } from "@remix-run/testing";
import { renderHook } from "@testing-library/react";
const renderRemixHook = <T,>(callback: () => T) => {
const RemixStub = ({ children }: PropsWithChildren) => {
const Remix = createRemixStub([
{
path: "/",
Component: () => {
return children;
},
},
]);
return <Remix />;
};
return renderHook(callback, { wrapper: RemixStub });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment