@@ -41,7 +41,6 @@ import {
4141} from 'quickpickle';
4242${ imports }
4343let World = getWorldConstructor()
44- const worldConfig = {}
4544
4645const common = {};
4746
@@ -70,9 +69,9 @@ export function renderFeature(feature:Feature, config:QuickPickleConfig) {
7069
7170 // Render the initScenario function, which will be called at the beginning of each scenario
7271 return `
73- const initScenario = async(scenario, tags) => {
74- let state = new World(worldConfig );
75- await state.init(worldConfig );
72+ const initScenario = async(context, scenario, tags) => {
73+ let state = new World(context );
74+ await state.init();
7675 state.common = common;
7776 state.info.feature = '${ q ( feature . keyword ) } : ${ q ( feature . name ) } ';
7877 state.info.scenario = scenario;
@@ -123,8 +122,8 @@ function renderRule(child:FeatureChild, config:QuickPickleConfig, tags:string[],
123122 return `
124123${ sp } describe('${ q ( child . rule ! . keyword ) } : ${ q ( child . rule ! . name ) } ', () => {
125124
126- ${ sp } const initRuleScenario = async (scenario, tags) => {
127- ${ sp } let state = await initScenario(scenario, tags);
125+ ${ sp } const initRuleScenario = async (context, scenario, tags) => {
126+ ${ sp } let state = await initScenario(context, scenario, tags);
128127${ sp } state.info.rule = '${ q ( child . rule ! . name ) } ';
129128${ backgroundSteps }
130129${ sp } return state;
@@ -168,8 +167,8 @@ function renderScenario(child:FeatureChild, config:QuickPickleConfig, tags:strin
168167 return `
169168${ sp } test${ attrs } .for(${ JSON . stringify ( paramValues ) } )(
170169${ sp } '${ q ( child . scenario ?. keyword || '' ) } : ${ describe } ',
171- ${ sp } async ({ ${ paramNames ?. join ( ', ' ) } }) => {
172- ${ sp } let state = await ${ initFn } (\`${ name } \`, ['${ tags . join ( "', '" ) || '' } ']);
170+ ${ sp } async ({ ${ paramNames ?. join ( ', ' ) } }, context ) => {
171+ ${ sp } let state = await ${ initFn } (context, \`${ name } \`, ['${ tags . join ( "', '" ) || '' } ']);
173172${ child . scenario ?. steps . map ( ( step , i ) => {
174173 let text = step . text . replace ( / ` / g, '\\`' )
175174 text = replaceParamNames ( text , true )
@@ -183,8 +182,8 @@ ${sp});
183182 }
184183
185184 return `
186- ${ sp } test${ attrs } ('${ q ( child . scenario ! . keyword ) } : ${ q ( child . scenario ! . name ) } ', async () => {
187- ${ sp } let state = await ${ initFn } ('${ q ( child . scenario ! . name ) } ', ['${ tags . join ( "', '" ) || '' } ']);
185+ ${ sp } test${ attrs } ('${ q ( child . scenario ! . keyword ) } : ${ q ( child . scenario ! . name ) } ', async (context ) => {
186+ ${ sp } let state = await ${ initFn } (context, '${ q ( child . scenario ! . name ) } ', ['${ tags . join ( "', '" ) || '' } ']);
188187${ renderSteps ( child . scenario ! . steps as Step [ ] , config , sp + ' ' ) }
189188${ sp } await afterScenario(state);
190189${ sp } });
0 commit comments