Closed
Description
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.