i'm having issues When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser.
import { render, screen, fireEvent } from "@testing-library/react";
import Home from "../Home";
import { BrowserRouter } from "react-router-dom";
describe("component testing", () => {
test("test", () => {
expect(true).toBe(true);
});
test("should make sure Input component wroking properly", () => {
const input = render(
<BrowserRouter>
<Home />
</BrowserRouter>
).getByTestId("addingAge");
expect(input).toBeTruthy();
});
test("should show user name in div component", () => {
const div = render(
<BrowserRouter>
<Home />
</BrowserRouter>
).getByTestId("showUser");
expect(div).not.toBeFalsy();
});
});