Member-only story
Reasons To Keep Assertions Out Of Page Object Models
The Power of Clean Code: Why Assertions Belong Outside POMs

In the Page Object Model (POM) pattern, the goal is to keep user interactions (clicking buttons, filling forms, etc.) separate from test assertions or validations. Page objects should only interact with web page elements, while the test files handle all the assertions. This ensures better separation of concerns, maintainability, and reusability of the code.
If you are behind the Medium paywall and can’t read this article, click here this publication is open to everyone.
Why This Approach is Important
- POM handles interactions, while the test files handle assertions and test logic.
- Keeping assertions in the test files allows easier updates when logic changes.
- A single Page Object can be reused across different tests without embedding test-specific logic.
- Test logic and assertions are centralized, making it easier to understand what the test is validating.
Example Without Assertions in Playwright POM
- Page Object Model (POM) — No Assertions
// loginPage.ts - POM for the Login Page using Playwright
import { Page } from…