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
All tests with `@tag` could be executed with `--grep @tag` option.
101
101
102
102
```sh
103
-
codeceptjs run --grep @slow
103
+
npx codeceptjs run --grep @slow
104
104
```
105
105
106
106
Use regex for more flexible filtering:
@@ -119,24 +119,30 @@ CodeceptJS provides a debug mode in which additional information is printed.
119
119
It can be turned on with `--debug` flag.
120
120
121
121
```sh
122
-
codeceptjs run --debug
122
+
npx codeceptjs run --debug
123
123
```
124
124
125
125
to receive even more information turn on `--verbose` flag:
126
126
127
127
```sh
128
-
codeceptjs run --verbose
128
+
npx codeceptjs run --verbose
129
129
```
130
130
131
-
And don't forget that you can pause execution and enter **interactive console** mode by calling `pause()` inside your test.
131
+
> You can pause execution and enter **interactive console** mode by calling `pause()` inside your test.
132
132
133
-
For advanced debugging use NodeJS debugger. In WebStorm IDE:
133
+
To see a complete internal debug of CodeceptJS use `DEBUG` env variable:
134
+
135
+
```sh
136
+
DEBUG=codeceptjs:* npx codeceptjs run
137
+
```
138
+
139
+
For an interactive debugging use NodeJS debugger. In **WebStorm**:
134
140
135
141
```sh
136
142
node $NODE_DEBUG_OPTION ./node_modules/.bin/codeceptjs run
137
143
```
138
144
139
-
For Visual Studio Code, add the following configuration in launch.json:
145
+
For **Visual Studio Code**, add the following configuration in launch.json:
140
146
141
147
```json
142
148
{
@@ -180,27 +186,54 @@ You can use this options for build your own [plugins](https://codecept.io/hooks/
180
186
});
181
187
```
182
188
183
-
### Timeout
189
+
### Timeout <Badge text="Updated in 3.2" type="warning"/>
190
+
191
+
Tests can get stuck due to various reasons such as network connection issues, crashed browser, etc.
192
+
This can make tests process hang. To prevent these situations timeouts can be used. Timeouts can be set explicitly for flaky parts of code, or implicitly in a config.
184
193
185
-
By default there is no timeout for tests, however you can change this value for a specific suite:
194
+
> Previous timeout implementation was disabled as it had no effect when dealing with steps and promises.
195
+
196
+
### Steps Timeout
197
+
198
+
It is possible to limit a step execution to specified time with `I.limitTime` command.
199
+
It will set timeout in seconds for the next executed step:
186
200
187
201
```js
188
-
Feature('Stop me').timeout(5000); // set timeout to 5s
202
+
// limit clicking to 5 seconds
203
+
I.limitTime(5).click('Link')
189
204
```
190
205
191
-
or for the test:
206
+
It is possible to set a timeout for all steps implicitly (except waiters) using [stepTimeout plugin](/plugins/#steptimeout).
207
+
208
+
### Tests Timeout
209
+
210
+
Test timeout can be set in seconds via Scenario options:
192
211
193
212
```js
194
-
// set timeout to 1s
195
-
Scenario("Stop me faster",({ I }) => {
196
-
// test goes here
197
-
}).timeout(1000);
213
+
// limit test to 20 seconds
214
+
Scenario('slow test that should be stopped', { timeout:20 }, ({ I }) => {
215
+
// ...
216
+
})
217
+
```
218
+
219
+
This timeout can be set globally in `codecept.conf.js` in seconds:
220
+
221
+
```js
222
+
exports.config= {
223
+
224
+
// each test must not run longer than 5 mins
225
+
timeout:300,
198
226
199
-
// alternative
200
-
Scenario("Stop me faster", {timeout:1000},({ I }) => {});
227
+
}
228
+
```
229
+
230
+
### Suites Timeout
201
231
202
-
// disable timeout for this scenario
203
-
Scenario("Don't stop me", {timeout:0},({ I }) => {});
232
+
A timeout for a group of tests can be set on Feature level via options.
233
+
234
+
```js
235
+
// limit all tests in this suite to 30 seconds
236
+
Feature('flaky tests', { timeout:30 })
204
237
```
205
238
206
239
@@ -249,45 +282,3 @@ Please note that some config changes can't be applied on the fly. For instance,
249
282
250
283
Configuration changes will be reverted after a test or a suite.
251
284
252
-
253
-
### Rerunning Flaky Tests Multiple Times <Badge text="Since 2.4" type="warning"/>
254
-
255
-
End to end tests can be flaky for various reasons. Even when we can't do anything to solve this problem it we can do next two things:
256
-
257
-
* Detect flaky tests in our suite
258
-
* Fix flaky tests by rerunning them.
259
-
260
-
Both tasks can be achieved with [`run-rerun` command](/commands/#run-rerun) which runs tests multiple times until all tests are passed.
261
-
262
-
You should set min and max runs boundaries so when few tests fail in a row you can rerun them until they are succeeded.
263
-
264
-
```js
265
-
// inside to codecept.conf.js
266
-
exports.config= { // ...
267
-
rerun: {
268
-
// run 4 times until 1st success
269
-
minSuccess:1,
270
-
maxReruns:4,
271
-
}
272
-
}
273
-
```
274
-
275
-
If you want to check all your tests for stability you can set high boundaries for minimal success:
0 commit comments