-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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]: @wdio/shared-store-service getValue returns undefined in onComplete hook #8335
Comments
Can you please provide a reproducible example? |
@christian-bromann Sorry.. Do you mean a full running code to reproduce this? The given screenshots would not help? |
Yes, because putting what you've shared into a fresh project, returns:
|
Oh that's strange.. I will work on getting the whole reproducible code. Meanwhile few pointers
|
@christian-bromann I have added the code here: https://github.com/mighty98/wdio-hooks npm run test -- --suite google I could reproduce the issue |
I see now. The problem is that all service hooks are run at the same time. So the server of the shared service is closed at the same time you are trying to receive a value from it. There are two options:
I think solution number 2 seems more resilient. Any contributions that resolves the bug are highly appreciated. Please take a look into our contribution guidelines and let us know if you have any questions. Cheers! |
@christian-bromann Thanks for the quick reply.... |
It is handled in the framework level, which is why I mention that contributions are welcome.
Yes,
Not sure what you mean. |
@christian-bromann Thanks. As for the required change, I may be very inexperienced to make the required change. But just removing onComplete hook from launcher here would resolve this?
|
I believe so. It might also require the removal of a test. |
@christian-bromann Can you please take a look at #8349 |
@christian-bromann Was i supposed to add a new version in package.json to be able to use this? |
If your versions are prefixed with a Closing as this bug was fixed and will be released soon. |
Have you read the Contributing Guidelines on issues?
WebdriverIO Version
7.19.7
Node.js Version
14.16.1
Mode
WDIO Testrunner
Which capabilities are you using?
No response
What happened?
Im creating a custom service where in onComplete hook i need to getValue from shared-store-service
In onPrepare hook i initialise the value
onPrepare = async () => { await setValue('result', { total: 0, pass: 0, fail: 0, duration: 0 }); };
in afterTest i update it
afterTest = async (test: Test, context: any, result: TestResult) => { const current: any = await getValue('result'); current.total += 1; result.passed ? (current.pass += 1) : (current.fail += 1); current.duration += result.duration; await setValue('result', current); };
And finally in onComplete i read it
onComplete = async () => { const current: any = await getValue('result'); console.log(
ON COMPLETE ${JSON.stringify(current)}); };
But it returns undefined
What is your expected behavior?
I should be able to fetch value in onComplete
How to reproduce the bug.
Steps are mentioned in description (Hope that would suffice)
Relevant log output
Code of Conduct
Is there an existing issue for this?
The text was updated successfully, but these errors were encountered: