adr/0001-aaa-test-structure.md
Proposed
Our tests are currently written in different styles, which makes them harder to read, understand, and maintain.
To improve readability and make it easier to debug failing tests, we want to standardize the structure of tests by following the well-known Arrange–Act–Assert (AAA) pattern.
We will adopt the AAA pattern for tests. Every test should follow this structure:
test('user can view their post', async ({ page }) => {
// Arrange
const user = await userFactory.create();
const post = await postFactory.create({ userId: user.id });
// Act
await page.goto(`/posts/${post.id}`);
// Assert
await expect(page.getByText(post.title)).toBeVisible();
});