Skip to content
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

Allow overriding of the asyncHookTimeout global property from the test itself #4255

Open
MurzNN opened this issue Aug 21, 2024 · 1 comment

Comments

@MurzNN
Copy link

MurzNN commented Aug 21, 2024

Description

I have a pretty slow before function in some tests, that exceeds the default asyncHookTimeout with 10000 ms.
I know, that I can increase the timeout in the external globals file.

But the problem is that I need to make these tests run on external environments with default settings, where is no access to editing the globals file.

Suggested solution

Would be great to have the ability to set (override) the asyncHookTimeout value from the test code itself, to make expectedly long-running tests work well in any environment with default settings.

Alternatives / Workarounds

No response

Additional Information

No response

@garg3133
Copy link
Member

If you're writing tests in BDD-style (describe/it), you can also set the asyncHookTimeout directly inside the describe body so that it applies to that particular test case only:

describe('tests', async function() {
  this.settings.globals.asyncHookTimeout = 5000;

  before(() => {
    console.log(browser.globals.asyncHookTimeout);
    browser.navigateTo('https://ecosia.org/')
    return new Promise((resolve) => {
      setTimeout(() => {
        resolve();
      }, 15000);
    });
  });

  it('loads local website', () => {
    browser.element.find('input[type=search]').assert.visible();
  });

  after(() => {
    browser.end();
  });
}); 

Note: Make sure that the callback passed to the describe function is a normal JS function (function () {}) and not an arrow function because this.setting would be undefined in an arrow function.

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

No branches or pull requests

2 participants