Skip to content

Commit

Permalink
3.2.2. release
Browse files Browse the repository at this point in the history
  • Loading branch information
DavertMik committed Nov 23, 2021
1 parent a2447b6 commit f554472
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 3.2.2

* [Playwright] Reverted removal of retry on context errors. Fixes #3130
* Timeout improvements by @nikocanvacom:
* Added priorites to timeouts
* Added `overrideStepLimits` to [stepTimeout plugin](https://codecept.io/plugins/#steptimeout) to override steps timeouts set by `limitTime`.
* Fixed step timeout not working due to override by NaN by test timeout #3126
* [Appium] Fixed logging error when `manualStart` is true. See #3140 by @nikocanvacom


## 3.2.1

> ♻️ This release fixes hanging of tests by reducing timeouts for automatic retries on failures.
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ You can use this options for build your own [plugins](https://codecept.io/hooks/
});
```
### Timeout <Badge text="Updated in 3.2" type="warning"/>
## Timeout <Badge text="Updated in 3.2" type="warning"/>
Tests can get stuck due to various reasons such as network connection issues, crashed browser, etc.
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.
Expand Down
11 changes: 11 additions & 0 deletions lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,17 @@ class Playwright extends Helper {
}

async _before() {
recorder.retry({
retries: 5,
when: err => {
if (!err || typeof (err.message) !== 'string') {
return false;
}
// ignore context errors
return err.message.includes('context');
},
});

if (this.options.restart && !this.options.manualStart) await this._startBrowser();
if (!this.isRunning && !this.options.manualStart) await this._startBrowser();

Expand Down
3 changes: 2 additions & 1 deletion lib/recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ module.exports = {
if (process.env.DEBUG) debug(`${currentQueue()}Queued | ${taskName}`);

return promise = Promise.resolve(promise).then((res) => {
const retryOpts = this.retries.slice(-1).pop();
// prefer options for non-conditional retries
const retryOpts = this.retries.sort((r1, r2) => r1.when && !r2.when).slice(-1).pop();
// no retries or unnamed tasks
if (!retryOpts || !taskName || !retry) {
const [promise, timer] = getTimeoutPromise(timeout, taskName);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codeceptjs",
"version": "3.2.1",
"version": "3.2.2",
"description": "Supercharged End 2 End Testing Framework for NodeJS",
"keywords": [
"acceptance",
Expand Down
15 changes: 15 additions & 0 deletions test/unit/recorder_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,20 @@ describe('Recorder', () => {
}, undefined, undefined, true);
return recorder.promise();
});

it('should prefer opts for non-when retry when possible', () => {
let counter = 0;
const errorText = 'noerror';
recorder.retry({ retries: 2 });
recorder.retry({ retries: 100, when: (err) => { return err.message === errorText; } });

recorder.add(() => {
counter++;
if (counter < 3) {
throw new Error(errorText);
}
}, undefined, undefined, true);
return recorder.promise();
});
});
});

0 comments on commit f554472

Please sign in to comment.