Skip to content

Commit 909c877

Browse files
DavertMikDavertMikclaude
authored
feat: add lifecycle hooks to page objects (_before, _after, _afterSuite) (#5512)
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: DavertMik <davert@testomat.io> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8e495d9 commit 909c877

File tree

10 files changed

+398
-59
lines changed

10 files changed

+398
-59
lines changed

docs/data.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ The most efficient way would be to allow test to control its data, i.e. the 3rd
1818
However, accessing database directly is not a good idea as database vendor, schema and data are used by application internally and are out of scope of acceptance test.
1919

2020
Today all modern web applications have REST or GraphQL API . So it is a good idea to use it to create data for a test and delete it after.
21-
API is supposed to be a stable interface and it can be used by acceptance tests. CodeceptJS provides 4 helpers for Data Management via REST and GraphQL API.
21+
API is supposed to be a stable interface and it can be used by acceptance tests. CodeceptJS provides helpers for Data Management via REST and GraphQL API, as well as **[Data Objects](/pageobjects#data-objects)** — class-based page objects with automatic cleanup via lifecycle hooks.
22+
23+
## Data Objects
24+
25+
For a lightweight, class-based approach to managing test data, see **[Data Objects](/pageobjects#data-objects)** in the Page Objects documentation. Data Objects let you create page object classes that manage API data with automatic cleanup via the `_after()` hook — no factory configuration needed.
2226

2327
## REST
2428

0 commit comments

Comments
 (0)