Skip to content

Customise world creation and type #7

Closed
@davidjgoss

Description

@davidjgoss

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions