Skip to content

retryTo not working with await in block #4110

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

Closed
cjhille opened this issue Jan 8, 2024 · 4 comments · Fixed by #4117
Closed

retryTo not working with await in block #4110

cjhille opened this issue Jan 8, 2024 · 4 comments · Fixed by #4117

Comments

@cjhille
Copy link
Contributor

cjhille commented Jan 8, 2024

Feature('foo');

Scenario('retry something', async ({ I }) => {

    I.amOnPage('http://example.org');
    
    // this works
    await retryTo( (tryNum) => {
        I.say(`${tryNum} try without await`);
        if (tryNum < 2) {
            I.say(`should fail and retry`);
            I.waitForVisible('.shouldFail', 1);
        }
        I.say(`should pass`);
    }, 2); 

    I.say(`---`);

    // this doesn't work
    await retryTo( async (tryNum) => {
        I.say(` ${tryNum} try with await`);
        await I.grabCurrentUrl();
        if (tryNum < 2) {
            I.say(`should fail and retry`);
            I.waitForVisible('.shouldFail', 1);
        }
        I.say(`should pass`);
    }, 2);
});

Details

  • CodeceptJS version: 3.5.7
  • NodeJS Version: 18.18.
  • Operating System: macos
  • playwright
@kobenguyent
Copy link
Collaborator

May you try with latest version? As if it happens with latest version, there is more chance that more ppl encounter the same issue.

@cjhille
Copy link
Contributor Author

cjhille commented Jan 8, 2024

@kobenguyent thanks for looking into this. i just tested it using a fresh npx codeceptjs init project with the current version -> same issue.

{
  "dependencies": {
    "codeceptjs": "^3.5.11"
  },
  "devDependencies": {
    "playwright": "^1.40.1"
  }
}

@cjhille
Copy link
Contributor Author

cjhille commented Jan 8, 2024

however this fix you suggested in slack seems to works.
image

@kobenguyent
Copy link
Collaborator

Thanks for @cjhille testing it out. Here is the fix #4117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants