Skip to content

Instantly share code, notes, and snippets.

@adamjarling
Created September 26, 2020 17:03
Show Gist options
  • Save adamjarling/a7c2b1da2621d77ed8c55a52500377cd to your computer and use it in GitHub Desktop.
Save adamjarling/a7c2b1da2621d77ed8c55a52500377cd to your computer and use it in GitHub Desktop.
import React from "react";
import { screen } from "@testing-library/react";
import {
renderWithRouterApollo,
withReactHookForm,
} from "../../../services/testing-helpers";
import ControlledMetadata from "./ControlledMetadata";
describe("Some component", () => {
beforeEach(() => {
// Wrap with React Hook Form's Provider
const Wrapped = withReactHookForm(ControlledMetadata);
// Wrap with any other Providers you may be using, like ApolloProvider, React Router, etc.
return renderWithRouterApollo(<Wrapped />,
{
mocks: [],
}
);
});
// Your tested component will be wrapped with React Hook Form's provider (and others)
it("renders controlled metadata component", async () => {
expect(await screen.findByTestId("controlled-metadata"));
});
...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment