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

Sharing state with World object #61

Open
jakohans76 opened this issue May 20, 2019 · 3 comments
Open

Sharing state with World object #61

jakohans76 opened this issue May 20, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@jakohans76
Copy link

I'm currently using jest and jest-cucumber with Typescript and new to this environment. I've set up a class to share the state which I reset in beforeEach. But if possible I'd like to have the option of adding the World object which is available for Ruby and in Cucumber.js. Is there such a feature with jest-cucumber? Or what is the best practice here? Thanks in advance.

@bencompton bencompton added the enhancement New feature or request label Jun 4, 2019
@bencompton
Copy link
Owner

The usual place for state being shared between steps is variables scoped to your defineFeature function. In many cases, steps are imported from other files, so there is no easy way to share state in that case. I can certainly see having something like Cucumber's "world", or SpecFlow's "scenario context".

@mainfraame
Copy link

@jakohans76 you should check out cucumber-jest. It's a transformer for jest that allows you to use the cucumber api, which already supports world context.

@bencompton bencompton added this to the autoBindSteps Gaps milestone Apr 10, 2021
@roma-inc
Copy link

The usual place for state being shared between steps is variables scoped to your defineFeature function. In many cases, steps are imported from other files, so there is no easy way to share state in that case. I can certainly see having something like Cucumber's "world", or SpecFlow's "scenario context".

This is a reasonable solution when you use defineFeature.
However you can't do that when using autoBindSteps.
It can be really powerful if there could be a way to share state when auto binding steps.

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

No branches or pull requests

4 participants