Slide 8
Slide 8 text
良いテストの例
form
のsubmit
時処理のテストはバグを拾う確率が比較的高い
ボタン押下時の挙動はアプリケーションにおいても重要性が高く、デグレする可能性も高い部類
test("
問い合わせ完了後に完了画面へ遷移すること", () => {
// ...
await user.click(
screen.getByRole("button", {
name: "
問い合わせ",
}),
);
expect(apiReq).toHaveBeenCalledTimes(1);
expect(apiReq).toHaveBeenLastCalledWith({
// ...
});
expect(
await screen.findByRole("heading", {
name: "
問い合わせが完了しました",
}),
).toBeInTheDocument();
});