Introduction
We use beforeEach and afterEach hooks to run some code before or after every test. This helps keep tests clean and avoid repeating the same steps.
When you want to open a webpage before each test runs.
When you need to reset data or clear cookies after each test.
When you want to log in once before every test in a group.
When you want to clean up test data after each test finishes.