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]: shared-store-service setValue does not work in onPrepare() as documented #7581

Closed
2 tasks done
yunj opened this issue Oct 22, 2021 · 4 comments · Fixed by #7593
Closed
2 tasks done

[🐛 Bug]: shared-store-service setValue does not work in onPrepare() as documented #7581

yunj opened this issue Oct 22, 2021 · 4 comments · Fixed by #7593
Labels
Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet

Comments

@yunj
Copy link

yunj commented Oct 22, 2021

WebdriverIO Version

7.16.0

Node.js Version

16.4.2

Mode

WDIO Testrunner

Which capabilities are you using?

{
    maxInstances: 1,
    browserName: 'chrome',
    'goog:chromeOptions': {
      args: ['--window-size=1200,800'],
    },
}

What happened?

We want to store environment-specific variables into shared store in onPrepare before running all tests and retrieve from each test's worker process, as documented at README.md. But val is always undefined unless we put await setValue('hello', 'world') in before().

await setValue('hello', 'world'); // set in onPrepare()
const val = await getValue('hello'); // get in each test

What is your expected behavior?

After setting values through shared store in onPrepare, all workers should be able to retrieve from the shared store.

How to reproduce the bug.

onPrepare: async function(config, capabilities) {
  await setValue('hello', 'world');
}

Relevant log output

Return undefined when getting the value through a key, await getValue('hello').

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
@yunj yunj added Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet labels Oct 22, 2021
@yunj yunj changed the title [🐛 Bug]: shared-store-service setValue does not work at onPrepare() [🐛 Bug]: shared-store-service setValue does not work in onPrepare() as documented Oct 22, 2021
@yunj
Copy link
Author

yunj commented Oct 22, 2021

Hi @Slashgear could you please have a look at why setValue in onPrepare() is not working as described in here? Thank you very much in advance.

@christian-bromann
Copy link
Member

But val is always undefined unless we put await setValue('hello', 'world') in before().

setValue is an async operation and need to be called with await, as described in the example. I can tweak the docs to explicitly emphasise this.

@yunj
Copy link
Author

yunj commented Oct 22, 2021

Hi @christian-bromann thanks for your reply. My code snippet shows await is being used to call setValue() otherwise it didn't work either in before() as described in the request. We want to do in onPrepare() so only execute once and can be accessed by all tests.

@christian-bromann
Copy link
Member

After investigation it appeared that this functionality was broken. A pull request was applied with a fix for it. Thanks for bringing this up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 Needs Triaging ⏳ No one has looked into the issue yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants