cucumber-js icon indicating copy to clipboard operation
cucumber-js copied to clipboard

Step undefined when we using api function

Open obouhlel opened this issue 4 months ago • 1 comments

👓 What did you see?

With this code:

import { runCucumber, loadConfiguration, loadSupport } from '@cucumber/cucumber/api'

async function run(name) {
	const { runConfiguration } = await loadConfiguration({ file: `./config/${name}.json` })

	const env = {
		cwd: process.cwd(),
		stdout: process.stdout,
		stderr: process.stderr,
		debug: false
	}
	
	const support = await loadSupport(runConfiguration, env)
	console.log(support)
  
	await runCucumber({ ...runConfiguration, support }, env, (message) => {
		(message)
	})
}

run("add").then(() => run("sub"))

The second time I run the scenario (or any subsequent runs), the steps are undefined. When I log the support variable using console.log, the stepDefinitions attribute is empty.

✅ What did you expect to see?

I expect the support variable to retain the stepDefinitions attribute.

📦 Which tool/library version are you using?

node: 18.20.4 cucumber: 11.0.1

🔬 How could we reproduce it?

In this repository, I have created a simple test to reproduce this issue.

  1. npm install
  2. npm run test

📚 Any additional context?

No response

obouhlel avatar Sep 26 '24 12:09 obouhlel