我目前正在尝试使用 Mocked Provider 测试样式组件,如下所示:
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();
});
});
});
Run Code Online (Sandbox Code Playgroud)
我在 TestResults 文件中使用 makeStyles 钩子
当我运行我的测试时,我收到以下错误:
TypeError: theme.spacing is not a function
Material-UI: the `styles` argument provided is invalid.
You …Run Code Online (Sandbox Code Playgroud) unit-testing reactjs react-apollo apollo-client react-testing-library