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/configuration.md
-77Lines changed: 0 additions & 77 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,83 +57,6 @@ exports.config = {
57
57
58
58
(Don't copy-paste this config, it's just demo)
59
59
60
-
## Hooks
61
-
62
-
Hooks are implemented as `bootstrap` and `teardown` options in config. You can use them to prepare test environment before execution and cleanup after.
63
-
They can be used to launch stop webserver, selenium server, etc. There are different sync and async ways to define bootstrap and teardown functions.
64
-
65
-
`bootstrap` and `teardown` options can be:
66
-
67
-
* JS file, executed as is (synchronously).
68
-
* JS file exporting a function; If function accepts a callback is executed asynchronously. See example:
69
-
70
-
Config (`codecept.json`):
71
-
72
-
```js
73
-
"bootstrap":"./bootstrap.js"
74
-
```
75
-
76
-
Bootstrap file (`bootstrap.js`):
77
-
78
-
```js
79
-
// bootstrap.js
80
-
var server =require('./app_server');
81
-
module.exports=function(done) {
82
-
// on error call done('error description') to stop
83
-
if (!server.validateConfig()) {
84
-
done("Can't execute server with invalid config, tests stopped");
85
-
}
86
-
// call done() to continue execution
87
-
server.launch(done);
88
-
}
89
-
```
90
-
91
-
Pass error description inside a callback (`done('error')`) to prevent test execution on bootstrap.
92
-
93
-
* JS file exporting an object with `bootstrap` and (or) `teardown` methods for corresponding hooks.
94
-
95
-
Config (`codecept.json`):
96
-
97
-
```js
98
-
"bootstrap":"./bootstrap.js"
99
-
"teardown":"./bootstrap.js"
100
-
```
101
-
102
-
Bootstrap file (`bootstrap.js`):
103
-
104
-
```js
105
-
// bootstrap.js
106
-
var server =require('./app_server');
107
-
module.exports= {
108
-
bootstrap:function(done) {
109
-
server.launch(done);
110
-
},
111
-
teardown:function(done) {
112
-
server.stop(done);
113
-
}
114
-
}
115
-
```
116
-
117
-
* JS function in case of dynamic config. If function accepts a callback is executed asynchronously. See example:
118
-
119
-
Config JS (`codecept.conf.js`):
120
-
121
-
```js
122
-
var server =require('./app_server');
123
-
124
-
exports.config= {
125
-
bootstrap:function(done) {
126
-
server.launch(done);
127
-
},
128
-
teardown:function(done) {
129
-
server.stop(done);
130
-
}
131
-
// ...
132
-
// other config options
133
-
}
134
-
135
-
```
136
-
137
60
## Profile
138
61
139
62
Using values from `process.profile` you can change the config dynamically.
0 commit comments