Skip to content

fix: no retry failed step after tryto block #4103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/plugin/retryFailedStep.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const event = require('../event');
const recorder = require('../recorder');
const container = require('../container');
const { log } = require('../output');

const defaultConfig = {
retries: 3,
@@ -99,7 +100,10 @@ module.exports = (config) => {
config.when = when;

event.dispatcher.on(event.step.started, (step) => {
if (process.env.TRY_TO) return;
if (process.env.TRY_TO === 'true') {
log('Info: RetryFailedStep plugin is disabled inside tryTo block');
return;
}

// if a step is ignored - return
for (const ignored of config.ignoredSteps) {
21 changes: 21 additions & 0 deletions test/unit/plugin/retryFailedStep_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { expect } = require('chai');

const retryFailedStep = require('../../../lib/plugin/retryFailedStep');
const tryTo = require('../../../lib/plugin/tryTo');
const within = require('../../../lib/within');
const session = require('../../../lib/session');
const container = require('../../../lib/container');
@@ -37,6 +38,26 @@ describe('retryFailedStep', () => {
return recorder.promise();
});

it('should not retry failed step when tryTo plugin is enabled', async () => {
tryTo();
retryFailedStep({ retries: 2, minTimeout: 1 });
event.dispatcher.emit(event.test.before, {});
event.dispatcher.emit(event.step.started, { name: 'click' });

try {
let counter = 0;
await recorder.add(() => {
counter++;
if (counter < 3) {
throw new Error('Retry failed step is disabled when tryTo plugin is enabled');
}
}, undefined, undefined, true);
return recorder.promise();
} catch (e) {
expect(e.message).equal('Retry failed step is disabled when tryTo plugin is enabled');
}
});

it('should not retry within', async () => {
retryFailedStep({ retries: 1, minTimeout: 1 });
event.dispatcher.emit(event.test.before, {});