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

Customise world creation and type #7

Open
davidjgoss opened this issue Feb 14, 2025 · 0 comments
Open

Customise world creation and type #7

davidjgoss opened this issue Feb 14, 2025 · 0 comments

Comments

@davidjgoss
Copy link
Collaborator

Currently the world is a plain object that we just create a fresh one of for each test case attempt.

We should allow customising this from support code. In cucumber-js this was setWorldConstructor which assumed a class and didn't allow for async initialisation. We could do it a little differently here, like:

import {World} from '@cucumber/node'

World(async () => {
  // do async stuff here
  return myWorld
})

So the user provides an (optionally async) function that creates an object (could be a class, or something else) and returns it.

As part of this, we should also ensure that TypeScript users can easily set the type of their world in one place, like a declaration extension, and have that automatically honoured in all their step and hook functions without explicitly converting the type.

@davidjgoss davidjgoss changed the title Customise world creation Customise world creation and type Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant