You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/bootstrap.md
+10-13Lines changed: 10 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,16 +11,14 @@ you can use the `bootstrap` and `teardown` config. Use it to start and stop a we
11
11
When using the [parallel execution](/parallel) mode, there are two additional hooks available; `bootstrapAll` and `teardownAll`. See [bootstrapAll & teardownAll](#bootstrapall-teardownall) for more information.
12
12
13
13
14
-
> ⚠ In CodeceptJS 2 bootstrap could be set as a function with `done` parameter. This way of handling async function was replaced with native async functions in CodeceptJS 3.
15
-
16
14
### Example: Bootstrap & Teardown
17
15
18
16
If you are using JavaScript-style config `codecept.conf.js`, bootstrap and teardown functions can be placed inside of it:
19
17
20
18
```js
21
-
var server =require('./app_server');
19
+
importserverfrom'./app_server.js';
22
20
23
-
exports.config= {
21
+
exportdefault {
24
22
tests:"./*_test.js",
25
23
helpers: {},
26
24
@@ -63,10 +61,10 @@ Using JavaScript-style config `codecept.conf.js`, bootstrapAll and teardownAll f
63
61
64
62
65
63
```js
66
-
constfs=require('fs');
64
+
importfsfrom'fs';
67
65
consttempFolder=process.cwd() +'/tmpFolder';
68
66
69
-
exports.config= {
67
+
exportdefault {
70
68
tests:"./*_test.js",
71
69
helpers: {},
72
70
@@ -95,13 +93,12 @@ exports.config = {
95
93
96
94
## Combining Bootstrap & BootstrapAll
97
95
98
-
It is quite common that you expect that bootstrapAll and bootstrap will do the same thing. If an application server is already started in `bootstrapAll` we should not run it again inside `bootstrap` for each worker. To avoid code duplication we can run bootstrap script only when we are not inside a worker. And we will use NodeJS `isMainThread` Workers API to detect that:
96
+
It is quite common that you expect that bootstrapAll and bootstrap will do the same thing. If an application server is already started in `bootstrapAll` we should not run it again inside `bootstrap` for each worker. To avoid code duplication we can run bootstrap script only when we are not inside a worker. CodeceptJS provides `store.workerMode` to detect if code is running in a worker process:
Copy file name to clipboardExpand all lines: docs/data.md
+84-1Lines changed: 84 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,90 @@ API is supposed to be a stable interface and it can be used by acceptance tests.
22
22
23
23
## Data Objects
24
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.
25
+
Data Objects are page object classes designed to manage test data via API. They use the REST helper (through `I`) to create data in a test and clean it up automatically via the `_after()` hook.
26
+
27
+
This is a lightweight alternative to [ApiDataFactory](#api-data-factory) — ideal when you want full control over data creation and cleanup logic without factory configuration.
// userData._after() runs automatically — deletes the created user
103
+
});
104
+
```
105
+
106
+
Data Objects can use any helper methods available via `I`, including `sendGetRequest`, `sendPutRequest`, and browser actions. They combine the convenience of managed test data with the flexibility of page objects.
107
+
108
+
**Learn more:** See [Page Objects](/pageobjects) for general page object patterns.
0 commit comments