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

World parameters available in BeforeAll / AfterAll hooks? #1547

Closed
jan-molak opened this issue Jan 20, 2021 · 2 comments
Closed

World parameters available in BeforeAll / AfterAll hooks? #1547

jan-molak opened this issue Jan 20, 2021 · 2 comments

Comments

@jan-molak
Copy link
Member

jan-molak commented Jan 20, 2021

Hi team!

Now that Cucumber.js has BeforeAll and AfterAll hooks, would it make sense to expose world parameters to them?

import { BeforeAll, Before } from '@cucumber/cucumber';

BeforeAll(function() {
    console.log(this.parameters.baseUrl);   // throws an error, parameters undefined
});

Before(function() {
    console.log(this.parameters.baseUrl);   // works fine
});

Consider the following use case:

  • Cucumber test suite interacts with a system that's deployed to multiple environments, each with its own URL
  • I'd like the test suite to be configurable to point to any of those environments, ideally using a parameter when invoking Cucumber (i.e. cucumber-js --world-parameters='{"baseUrl":"prod.example.com"}'; this could be put into a profile, but the idea is the same)
  • Let's also assume that the integration client I use to talk to those environments is expensive to create (say a DB connection), so I'd prefer to do the configuration step only once for all the scenarios, ideally in a BeforeAll hook.

What I'd love is to use the same this.parameters object that's available in all the other Cucumber steps in BeforeAll and AfterAll hooks. However, before proposing a PR I wanted to discuss the idea with you first @davidjgoss @charlierudolph @jbpros

Do you think we should have this functionality implemented in Cucumber.js? Does it make sense? Is there a better way to accomplish this goal?

@Tallyb
Copy link

Tallyb commented Jan 25, 2021

I do something similar by using an env param DB_URL=XXXX cucumber-js ... and storing it on global.

@davidjgoss
Copy link
Contributor

Hey @jan-molak, this seems to overlap quite a bit with #1393 - hope you're fine with me closing this so we can perhaps restart that discussion there?

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

No branches or pull requests

3 participants