Skip to content

feat: page object lifecycle hooks and Data Objects#5512

Open
DavertMik wants to merge 1 commit into4.xfrom
feat/page-obj-improv
Open

feat: page object lifecycle hooks and Data Objects#5512
DavertMik wants to merge 1 commit into4.xfrom
feat/page-obj-improv

Conversation

@DavertMik
Copy link
Copy Markdown
Contributor

Summary

  • Add lifecycle hooks (_before, _after, _beforeSuite, _afterSuite) to page objects, mirroring the helper hook system
  • _before() runs lazily on first method call per test (not on injection), _after() only runs for page objects actually used
  • New lib/listener/pageobjects.js wires hooks into the event system, registered after helpers listener
  • Document class-based page objects as the recommended pattern with const { I } = inject() + export default ClassName
  • Document Data Objects pattern: page object classes that manage test data via REST with automatic _after() cleanup

Test plan

  • 4 new runner tests verify hook ordering, single-call guarantee, unused-PO skip, and no-hook-PO skip
  • All 10 existing page object runner tests pass (backward compat)
  • All 33 container unit tests pass
  • Acceptance tests with Playwright

🤖 Generated with Claude Code

Page objects now support lifecycle hooks that mirror the helper hook system.
_before() runs lazily on first method call per test, _after() runs after
each test for used page objects, and _beforeSuite()/_afterSuite() run for
all page objects that define them. Also documents Data Objects pattern for
REST-based test data management with automatic cleanup.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant