Skip to content

Commit e37977a

Browse files
DavertMikDavertMikclaude
authored
Remove deprecated I.retry() and I.limitTime() (#5567)
* Remove deprecated I.retry() and I.limitTime() Both were deprecated in 3.x; removed in 4.x as part of the major break. The step options API (step.retry() / step.timeout() passed as the last step argument) is the replacement and behaves identically without the 3.x footgun of leaking config onto the following step. - lib/actor.js: drop retry()/limitTime() and now-unused imports - typings: remove retry()/limitTime() actor declarations - migrate runner fixtures and actor unit test to step.retry()/step.timeout() - migration-4.md: document removal with 3.x->4.x mappings - fix stale I.retry()/I.limitTime() references in docs and plugin doc-comments Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Fix dtslint: drop removed clickLink/retry/limitTime from typings tests - typings/tests/helpers/Playwright.types.ts + PlaywrightTs.types.ts: remove clickLink expectType assertions (clickLink was removed from the Playwright helper) - typings/tests/actor.types.ts: drop the now-invalid I.retry() calls; document that retry()/limitTime() were removed (I is `any` here so the removal cannot be asserted at the type level) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: DavertMik <davert@testomat.io> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 974e241 commit e37977a

17 files changed

Lines changed: 34 additions & 77 deletions

File tree

docs/custom-helpers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ _before() {
212212
}
213213
```
214214

215-
`recorder.retry` acts similarly to `I.retry()` and accepts the same parameters. It expects the `when` parameter to be set so it would handle only specific errors and not to retry for every failed step.
215+
`recorder.retry` registers a retry rule at the recorder level and accepts the same options as `step.retry()` (`retries`, `minTimeout`, `when`, ...). It expects the `when` parameter to be set so it would handle only specific errors and not to retry for every failed step.
216216

217217
Retry rules are available in array `recorder.retries`. The last retry rule can be disabled by running `recorder.retries.pop()`;
218218

docs/detox.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ CodeceptJS provides next features over standard Detox:
3131

3232
* **Unified API**. The same test can be executed in Appium or Detox. Unified API helps different teams to use the same syntax and easy port tests from one engine to another.
3333
* [Interactive pause](/basics#pause). When starting/stopping an application takes a long time, debugging and writing tests can be hard. CodeceptJS solves this by pausing an execution and letting you try different commands and locators. With this feature a test can be writtern during one running session.
34-
* [Auto-retries](/basics#retries) using `retryFailedStepPlugin` and `I.retry()`
34+
* [Auto-retries](/basics#retries) using the `retryFailedStep` plugin and `step.retry()`
3535
* **Cross-Platform testing** - one test can be executed on different engines. When needed, platform-specific actions and locators can be easily applied.
3636

3737
## A Test

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Scenario('Create a new store', async ({ I, login, SettingsPage }) => {
100100
I.fillField('Email', faker.internet.email());
101101
I.fillField('Telephone', faker.phone.phoneNumberFormat());
102102
I.selectInDropdown('Status', 'Active'); // Use custom methods
103-
I.retry(2).click('Create'); // Retry flaky step
103+
I.click('Create', step.retry(2)); // Retry flaky step
104104
I.waitInUrl('/settings/setup/stores'); // Explicit waiter
105105
I.see(storeName, '.settings'); // Assert text present inside an element (located by CSS)
106106
const storeId = await I.grabTextFrom('#store-id'); // Use await to get information from browser

docs/migration-4.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,18 +473,26 @@ Use one of:
473473
474474
The `customLocators` strategy registration in Playwright config is removed. Use the `customLocator` plugin or built-in ARIA locators (`{ role: 'button', name: 'Submit' }`).
475475
476-
### `I.retry()` is deprecated
476+
### `I.retry()` and `I.limitTime()` removed
477477
478-
Use the step options API:
478+
Both were deprecated in 3.x and are **removed in 4.x**. They configured the *next* step through a chained call; the replacement is the step options API — pass a `step.*` config as the **last argument** of the step itself.
479479
480480
```js
481481
import step from 'codeceptjs/steps'
482482

483-
I.click('Submit', step.retry(3))
484-
I.fillField('Email', 'a@b.c', step.timeout(10))
483+
// 3.x (removed) → 4.x
484+
I.retry(3).click('Submit') // I.click('Submit', step.retry(3))
485+
I.limitTime(10).fillField('Email', 'a@b.c') // I.fillField('Email', 'a@b.c', step.timeout(10))
486+
```
487+
488+
`step.*` configs are also composable with the other step options:
489+
490+
```js
485491
I.click('Add', step.opts({ elementIndex: 2 }))
486492
```
487493
494+
The behavior is unchanged — the option applies only to the step it is attached to, not to subsequent steps (this also fixes the 3.x footgun where `I.retry()` could leak retry settings onto the following step). `recorder.retry()` is unaffected and remains available for custom helpers.
495+
488496
### `within` Is Now an Effect
489497
490498
In 3.x, `within(...)` was a global statement available everywhere. In 4.x it's an effect alongside `tryTo`, `retryTo`, and `hopeThat`. Under `noGlobals: true` you must import it:

docs/plugins/retryFailedStep.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ plugins: {
6161

6262
#### Disable Per Test
6363

64-
This plugin can be disabled per test. In this case you will need to stet `I.retry()` to all flaky steps:
64+
This plugin can be disabled per test. In this case you will need to add `step.retry()` to all flaky steps:
6565

6666
Use scenario configuration to disable plugin for a test
6767

docs/plugins/stepTimeout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Run tests with plugin enabled:
2929

3030
* `timeout` - global step timeout, default 150 seconds
3131

32-
* `overrideStepLimits` - whether to use timeouts set in plugin config to override step timeouts set in code with I.limitTime(x).action(...), default false
32+
* `overrideStepLimits` - whether to use timeouts set in plugin config to override step timeouts set in code with `I.action(..., step.timeout(x))`, default false
3333

3434
* `noTimeoutSteps` - an array of steps with no timeout. Default:
3535

docs/timeouts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ plugins: {
118118
When multiple timeouts are configured, CodeceptJS applies them in priority order:
119119

120120
1. **stepTimeoutHard** — plugin with `overrideStepLimits: true`
121-
2. **codeLimitTime**`step.timeout()` or `I.limitTime()`
121+
2. **codeLimitTime**`step.timeout()`
122122
3. **stepTimeoutSoft** — plugin with `overrideStepLimits: false`
123123
4. **testOrSuite** — global test/suite timeout
124124

lib/actor.js

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import Step, { MetaStep } from './step.js'
22
import recordStep from './step/record.js'
3-
import retryStep from './step/retry.js'
43
import { methodsOfObject } from './utils.js'
5-
import { TIMEOUT_ORDER } from './timeout.js'
64
import event from './event.js'
7-
import store from './store.js'
85
import output from './output.js'
96
import Container from './container.js'
107

@@ -30,38 +27,6 @@ class Actor {
3027
output.say(msg, `${color}`)
3128
})
3229
}
33-
34-
/**
35-
* set the maximum execution time for the next step
36-
* @function
37-
* @param {number} timeout - step timeout in seconds
38-
* @return {this}
39-
* @inner
40-
*/
41-
limitTime(timeout) {
42-
if (!store.timeouts) return this
43-
44-
console.log('I.limitTime() is deprecated, use step.timeout() instead')
45-
46-
event.dispatcher.prependOnceListener(event.step.before, step => {
47-
output.log(`Timeout to ${step}: ${timeout}s`)
48-
step.setTimeout(timeout * 1000, TIMEOUT_ORDER.codeLimitTime)
49-
})
50-
51-
return this
52-
}
53-
54-
/**
55-
* @function
56-
* @param {*} [opts]
57-
* @return {this}
58-
* @inner
59-
*/
60-
retry(opts) {
61-
console.log('I.retry() is deprecated, use step.retry() instead')
62-
retryStep(opts)
63-
return this
64-
}
6530
}
6631

6732
/**

lib/plugin/retryFailedStep.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const RETRY_PRIORITIES = {
7777
*
7878
* #### Disable Per Test
7979
*
80-
* This plugin can be disabled per test. In this case you will need to stet `I.retry()` to all flaky steps:
80+
* This plugin can be disabled per test. In this case you will need to add `step.retry()` to all flaky steps:
8181
*
8282
* Use scenario configuration to disable plugin for a test
8383
*

lib/plugin/stepTimeout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const defaultConfig = {
3232
* #### Configuration:
3333
*
3434
* * `timeout` - global step timeout, default 150 seconds
35-
* * `overrideStepLimits` - whether to use timeouts set in plugin config to override step timeouts set in code with I.limitTime(x).action(...), default false
35+
* * `overrideStepLimits` - whether to use timeouts set in plugin config to override step timeouts set in code with `I.action(..., step.timeout(x))`, default false
3636
* * `noTimeoutSteps` - an array of steps with no timeout. Default:
3737
* * `amOnPage`
3838
* * `wait*`

0 commit comments

Comments
 (0)