Skip to content

Commit 2f8bc5c

Browse files
DavertMikclaude
andauthored
DOC: rewrite retry.md for clarity and concision (#5496)
* DOC: rewrite retry.md — remove duplication, clarify healing section - Remove repeated "Common Patterns" and "Configuration Reference" sections - Move self-healing to step-level position (after retryTo, before scenario retries) - Explain AI healing flow as bullet list showing what happens at each stage - Link to /heal and /ai instead of duplicating their content Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * DOC: update locators.md — add ARIA/role locators, context param, and ID locator types Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1501b70 commit 2f8bc5c

File tree

16 files changed

+1121
-6706
lines changed

16 files changed

+1121
-6706
lines changed

docs/advanced.md

Lines changed: 0 additions & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -81,37 +81,6 @@ Data(function*() {
8181
8282
*HINT: If you don't use DataTable. add `toString()` method to each object added to data set, so the data could be pretty printed in a test name*
8383
84-
## Tags
85-
86-
Append `@tag` to your test name, so
87-
88-
```js
89-
Scenario('update user profile @slow')
90-
```
91-
92-
Alternativly, use `tag` method of Scenario to set additional tags:
93-
94-
```js
95-
Scenario('update user profile', ({ }) => {
96-
// test goes here
97-
}).tag('@slow').tag('important');
98-
```
99-
100-
All tests with `@tag` could be executed with `--grep '@tag'` option.
101-
102-
```sh
103-
codeceptjs run --grep '@slow'
104-
```
105-
106-
Use regex for more flexible filtering:
107-
108-
* `--grep '(?=.*@smoke2)(?=.*@smoke3)'` - run tests with @smoke2 and @smoke3 in name
109-
* `--grep "\@smoke2|\@smoke3"` - run tests with @smoke2 or @smoke3 in name
110-
* `--grep '((?=.*@smoke2)(?=.*@smoke3))|@smoke4'` - run tests with (@smoke2 and @smoke3) or @smoke4 in name
111-
* `--grep '(?=.*@smoke2)^(?!.*@smoke3)'` - run tests with @smoke2 but without @smoke3 in name
112-
* `--grep '(?=.*)^(?!.*@smoke4)'` - run all tests except @smoke4
113-
114-
11584
11685
## Debug
11786
@@ -185,167 +154,3 @@ You can use this options for build your own [plugins](https://codecept.io/hooks/
185154
...
186155
});
187156
```
188-
189-
## Timeout
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.
193-
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:
200-
201-
```js
202-
// limit clicking to 5 seconds
203-
I.limitTime(5).click('Link')
204-
```
205-
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:
211-
212-
```js
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,
226-
227-
}
228-
```
229-
230-
### Suites Timeout
231-
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 })
237-
```
238-
239-
### Timeout Confguration
240-
241-
<Badge text="Updated in 3.4" type="warning"/>
242-
243-
Timeout rules can be set globally via config.
244-
245-
To set a timeout for all running tests provide a **number of seconds** to `timeout` config option:
246-
247-
248-
```js
249-
// inside codecept.conf.js or codecept.conf.ts
250-
timeout: 30, // limit all tests in all suites to 30 secs
251-
```
252-
253-
It is possible to tune this configuration for a different groups of tests passing options as array and using `grep` option to filter tests:
254-
255-
```js
256-
// inside codecept.conf.js or codecept.conf.ts
257-
258-
timeout: [
259-
10, // default timeout is 10secs
260-
261-
// but increase timeout for slow tests
262-
{
263-
grep: '@slow',
264-
Feature: 50
265-
},
266-
]
267-
```
268-
269-
> ℹ️ `grep` value can be string or regexp
270-
271-
It is possible to set a timeout for Scenario or Feature:
272-
273-
```js
274-
// inside codecept.conf.js or codecept.conf.ts
275-
timeout: [
276-
277-
// timeout for Feature with @slow in title
278-
{
279-
grep: '@slow',
280-
Feature: 50
281-
},
282-
283-
// timeout for Scenario with 'flaky0' .. `flaky1` in title
284-
{
285-
// regexp can be passed to grep
286-
grep: /flaky[0-9]/,
287-
Scenario: 10
288-
},
289-
290-
// timeout for all suites
291-
{
292-
Feature: 20
293-
}
294-
]
295-
```
296-
297-
Global timeouts will be overridden by explicit timeouts of a test or steps.
298-
299-
### Disable Timeouts
300-
301-
To execute tests ignoring all timeout settings use `--no-timeouts` option:
302-
303-
```
304-
npx codeceptjs run --no-timeouts
305-
```
306-
307-
## Dynamic Configuration
308-
309-
Helpers can be reconfigured per scenario or per feature.
310-
This might be useful when some tests should be executed with different settings than others.
311-
In order to reconfigure tests use `.config()` method of `Scenario` or `Feature`.
312-
313-
```js
314-
Scenario('should be executed in firefox', ({ I }) => {
315-
// I.amOnPage(..)
316-
}).config({ browser: 'firefox' })
317-
```
318-
319-
In this case `config` overrides current config of the first helper.
320-
To change config of specific helper pass two arguments: helper name and config values:
321-
322-
```js
323-
Scenario('should create data via v2 version of API', ({ I }) => {
324-
// I.amOnPage(..)
325-
}).config('REST', { endpoint: 'https://api.mysite.com/v2' })
326-
```
327-
328-
Config can also be set by a function, in this case you can get a test object and specify config values based on it.
329-
This is very useful when running tests against cloud providers, like BrowserStack. This function can also be asynchronous.
330-
331-
```js
332-
Scenario('should report to BrowserStack', ({ I }) => {
333-
// I.amOnPage(..)
334-
}).config((test) => {
335-
return { desiredCapabilities: {
336-
project: test.suite.title,
337-
name: test.title,
338-
}}
339-
});
340-
```
341-
342-
Config changes can be applied to all tests in suite:
343-
344-
```js
345-
Feature('Admin Panel').config({ url: 'https://mysite.com/admin' });
346-
```
347-
348-
Please note that some config changes can't be applied on the fly. For instance, if you set `restart: false` in your config and then changing value `browser` won't take an effect as browser is already started and won't be closed untill all tests finish.
349-
350-
Configuration changes will be reverted after a test or a suite.
351-

0 commit comments

Comments
 (0)