In this lesson, let's see how to avoid repeating some code in the tests.
Now, we use a Factory to create a user in every test. We will extract this part using Pest hooks.
Pest Hooks
Pest offers four hook methods:
-
beforeEach()
-
afterEach()
-
beforeAll()
-
afterAll()
Each has a name that tells when it is being executed. For example, to create a user before the test is run, we can use...