-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
WebdriverIO Version
latest
Node.js Version
v18
Mode
WDIO Testrunner
Which capabilities are you using?
capabilities: [{
browserName: 'chrome'
}],What happened?
I've encountered inconsistent behaviour when trying to skip tests using context.skip() within mocha hook beforeTest.
Specifically, when I define async beforeTest and call context.skip(), the test does not get skipped.
async beforeTest (test, context) {
context.skip()
}
However, when I define an sync beforeTest and call context.skip(), the test get skipped as expected
beforeTest: function (test, context) {
context.skip()
}
Upon analysis, I found that we are resolving the rejected promise that is returned.
webdriverio/packages/wdio-utils/src/shim.ts
Lines 69 to 74 in ef5f2e5
| if (result && typeof result.then === 'function') { | |
| return result.then(resolve, (e: Error) => { | |
| log.error(e.stack || e.message) | |
| resolve(e) | |
| }) | |
| } |
I would appreciate your thoughts on rejecting the rejected promise with a message like sync|async skip; aborting execution to ensure the test is skipped as intended.
What is your expected behavior?
When context.skip() is called in an async beforeTest, the test should be skipped, just as it works with sync beforeTest.
How to reproduce the bug.
conf file
// wdio.conf.js
export const config = {
runner: 'local',
specs: [
'./test/specs/**/*.js'
],
exclude: [
],
capabilities: [{
browserName: 'chrome'
}],
logLevel: 'error',
bail: 0,
waitforTimeout: 10000,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
framework: 'mocha',
reporters: ['spec'],
mochaOpts: {
ui: 'bdd',
timeout: 60000,
},
async beforeTest (test, context) {
context.skip()
}
}
test file
//test/specs/test.skip.js
describe('SKIP TEST', () => {
it('TO SKIP', () => {
console.log('SHOULD NOT BE PRINTED...')
})
})
Relevant log output
[0-0] RUNNING in chrome - file:///test/specs/test.skip.js
[0-0] 2024-09-19T16:29:20.386Z ERROR @wdio/utils:shim: sync skip; aborting execution
[0-0] SHOULD NOT BE PRINTED...
[0-0] PASSED in chrome - file:///test/specs/test.skip.jsCode 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