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

[🐛 Bug]: Mocha Step Definition Timeout #12714

Open
3 tasks done
talbss opened this issue Apr 17, 2024 · 4 comments
Open
3 tasks done

[🐛 Bug]: Mocha Step Definition Timeout #12714

talbss opened this issue Apr 17, 2024 · 4 comments
Labels
Bug 🐛 help wanted Issues that are free to take by anyone interested

Comments

@talbss
Copy link

talbss commented Apr 17, 2024

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

8.36.0

Node.js Version

v20.12.1

Mode

Standalone Mode

Which capabilities are you using?

mochaOpts: {
        ui: 'bdd',
        timeout: 3000
    },

What happened?

mocha offers the possibility to overwrite the test timeouts https://mochajs.org/#timeouts

At suite level:

describe('My mocha timeout tests - global overwrite', function () {
    this.timeout(6000);

    it('should not timeout: pause > 3000 and < 6000', async function() {
        console.log('test timeout: ' + this.test._timeout);
        await browser.pause(5000);
        console.log('test timeout: ' + this.test._timeout);
    })

})

At test level

describe('My mocha timeout tests - per it overwrite', function () {

    it('should not timeout: pause > 3000 and < 6000', async function() {
        console.log('test timeout before overwrite: ' + this.test._timeout);
        this.timeout(6000);
        console.log('test timeout after overwrite: ' + this.test._timeout);
        await browser.pause(5000);
    })

})

What is your expected behavior?

The mocha timeout (3000ms) defined in the wdio.conf.js file should be overwritten at suite level or test level:

At test level, the overwritten timeout is not taken into account, even if it is correctly overritten:

this code:

it('should not timeout: pause > 3000 and < 6000', async function() {
        console.log('test timeout before overwrite: ' + this.test._timeout);
        this.timeout(6000);
        console.log('test timeout after overwrite: ' + this.test._timeout);
        await browser.pause(5000);
    })

gives following output:

[0-0] test timeout before overwrite: 3000   //timeout in wdio.conf.js
[0-0] test timeout after overwrite: 6000 //new timeout specified in test block

but timeouts after 5000ms

How to reproduce the bug.

clone https://github.com/talbss/wdio-v8

npm i
npx wdio

Relevant log output

"spec" Reporter:
------------------------------------------------------------------
[chrome 123.0.6312.123 windows #0-0] Running: chrome (v123.0.6312.123) on windows
[chrome 123.0.6312.123 windows #0-0] Session ID: 364b89eb2adc90051f2bc7d59ea827c0
[chrome 123.0.6312.123 windows #0-0]
[chrome 123.0.6312.123 windows #0-0] » \example.e2e.js
[chrome 123.0.6312.123 windows #0-0] My mocha timeout tests - global overwrite
[chrome 123.0.6312.123 windows #0-0]     should not timeout: pause > 3000 and < 6000
[chrome 123.0.6312.123 windows #0-0]
[chrome 123.0.6312.123 windows #0-0] My mocha timeout tests - per it overwrite
[chrome 123.0.6312.123 windows #0-0]     should not timeout: pause > 3000 and < 6000
[chrome 123.0.6312.123 windows #0-0]
[chrome 123.0.6312.123 windows #0-0] 1 passing (8s)
[chrome 123.0.6312.123 windows #0-0] 1 failing
[chrome 123.0.6312.123 windows #0-0]
[chrome 123.0.6312.123 windows #0-0] 1) My mocha timeout tests - per it overwrite should not timeout: pause > 3000 and < 6000
[chrome 123.0.6312.123 windows #0-0] Timeout
[chrome 123.0.6312.123 windows #0-0] Error: Timeout
[chrome 123.0.6312.123 windows #0-0]     at listOnTimeout (node:internal/timers:573:17)
[chrome 123.0.6312.123 windows #0-0]     at process.processTimers (node:internal/timers:514:7)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues
@talbss talbss added Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet labels Apr 17, 2024
@talbss
Copy link
Author

talbss commented Apr 17, 2024

new issue created as requested here:

@christian-bromann christian-bromann added help wanted Issues that are free to take by anyone interested and removed Needs Triaging ⏳ No one has looked into the issue yet labels Apr 17, 2024
@wdio-bot
Copy link
Contributor

Thanks for reporting!

We greatly appreciate any contributions that help resolve the bug. While we understand that active contributors have their own priorities, we kindly request your assistance if you rely on this bug being fixed. We encourage you to take a look at our contribution guidelines or join our friendly Discord development server, where you can ask any questions you may have. Thank you for your support, and cheers!

@ccharnkij
Copy link
Contributor

@talbss I think because the way wdio wraps mocha, setting this.timeout() inside of it() would not work. To set timeout for it(), try putting timeout after like this instead

it('Test timeout mocha', async function () {
    
}).timeout(120000);

@talbss
Copy link
Author

talbss commented Apr 30, 2024

Yes i know and i have already done this change on my tests.
But it is a regression since it was correctly working on v7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 help wanted Issues that are free to take by anyone interested
Projects
None yet
Development

No branches or pull requests

4 participants