P粉6484692852023-08-16 00:46:15
也許嘗試這段程式碼:
describe("App", () => { it("正确渲染应用程序", async() => { render( < App / > ); // 根据您的UI组件添加更具体的断言 expect(screen.getByText("Fetch Api, display 1 card, add comments and likes to those comments")).toBeInTheDocument(); }); it("正确处理上一个按钮的点击", async() => { render( < App / > ); fireEvent.click(screen.getByRole("button", { name: "<" })); // 添加断言以检查点击上一个按钮后的行为 }); it("正确处理下一个按钮的点击", async() => { render( < App / > ); fireEvent.click(screen.getByRole("button", { name: ">" })); // 添加断言以检查点击下一个按钮后的行为 }); });