Testing the CreatePost component
Follow step-by-step instructions to write test cases for the CreatePost component.
We'll cover the following...
In the src/components/posts/__tests__
directory, create a new file called CreatePost.test.js
. We’ll start with the necessary imports and the definition of the test
function:
Press + to interact
import { render, screen, fireEvent } from "../../../helpers/test-utils";import userEvent from "@testing-library/user-event";import CreatePost from "../CreatePost";import { faker } from "@faker-js/faker";test("Renders CreatePost component", async () => {...});
We can notice the introduction of the async
...