Hello guys!
Thanks for your amazing work and especially for the React wrapper around Moralis.
I have a plain vanilla React app that I would like to unit test.
What is the good approach to to the following?
import { render, screen } from "@testing-library/react";
import App from "./App";
import { MoralisProvider } from "react-moralis";
jest.mock("react-moralis"); // I tried to mock MoralisProvider
it("should render the app", () => {
render(
<MoralisProvider>
<App />
</MoralisProvider>
);
const linkElement = screen.getByText(/Hello world/i);
expect(linkElement).toBeInTheDocument();
});
If I do not wrap the App, I get this error.
it("should render the app", () => {
render(<App />);
const linkElement = screen.getByText(/Hello world/i);
expect(linkElement).toBeInTheDocument();
});
β should render the app
TypeError: Cannot destructure property 'authenticate' of '(0 , _reactMoralis.useMoralis)(...)' as it is undefined.
14 |
15 | const App = () => {
> 16 | const { authenticate, logout, isAuthenticated, user } = useMoralis();