I'm currently trying to test a styled component with a Mocked Provider as follows:
import React from "react";
import TestResults from "./TestResults";
import {
render,
cleanup,
findByTestId,
findByText,
waitForElement,
} from "@testing-library/react";
import { MockedProvider } from "@apollo/react-testing";
describe("TestResultsComponent", () => {
describe("Overall", () => {
it("should render successfully - base", async () => {
const { getByText } = render(
<MockedProvider>
<TestResults />
</MockedProvider>
);
expect(getByText("Preview")).toBeInTheDocument();
});
});
});
I'm using the makeStyles hook in the TestResults file
When I run my tests, I receive the following error:
TypeError: theme.spacing is not a function
Material-UI: the `styles` argument provided is invalid.
You are providing a function without a theme in the context.
One of the parent elements needs to use a ThemeProvider.
I'm not sure if I should mock out the implementation of makeStyles. This is the my first time seeing an error like this, I have been testing other components that use the same hook and it has not been an issue.