cucumber / cucumber-js

Cucumber for JavaScript
https://cucumber.io
MIT License
5.05k stars 1.09k forks source link

SetDefaultTimeout not working on v6 #2066

Closed fguidobaldi closed 2 years ago

fguidobaldi commented 2 years ago

👓 What did you see?

I cannot use setDefaultTimeout to set a default timeout globally.

TypeError: Cannot set properties of undefined (setting 'defaultTimeout') at setDefaultTimeout (/Users/fguidobaldi/Repositorios/fury_qaautomation/node_modules/cucumber/lib/support_code_library_builder/index.js:33:37) at Object. (/Users/fguidobaldi/Repositorios/fury_qaautomation/features/steps/given.js:2:1) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at /Users/fguidobaldi/Repositorios/fury_qaautomation/node_modules/@cucumber/cucumber/lib/api/support.js:14:32 at Array.map () at getSupportCodeLibrary (/Users/fguidobaldi/Repositorios/fury_qaautomation/node_modules/@cucumber/cucumber/lib/api/support.js:14:18) at runCucumber (/Users/fguidobaldi/Repositorios/fury_qaautomation/node_modules/@cucumber/cucumber/lib/api/run_cucumber.js:33:53) at async Cli.run (/Users/fguidobaldi/Repositorios/fury_qaautomation/node_modules/@cucumber/cucumber/lib/cli/index.js:45:29) at async Object.run [as default] (/Users/fguidobaldi/Repositorios/fury_qaautomation/node_modules/@cucumber/cucumber/lib/cli/run.js:34:18)

📦 Which tool/library version are you using?

I'm using Cucumber v.6.0.7 (since newer versions doesn't support Allure Report integration).

🔬 How could we reproduce it?

Currently I'm using these lines on top of my given.js file, where I group all my given steps.

const {Given, setDefaultTimeout} = require('cucumber'); setDefaultTimeout(15000);

When I try to run any scenario, it throws an error. Debugging, I found out that the "options" field, inside "cucumber/lib/support_code_library_builder/index.js" is undefined, but I didn't found out why.

📚 Any additional context?


davidjgoss commented 2 years ago

Hey @fguidobaldi, from the stack trace you provided it looks like you have both versions of cucumber in play. Your step code is requiring cucumber, but what's actually running is @cucumber/cucumber. I'd suggest removing the latter module (use npm why @cucumber/cucumber if you're not sure where it's coming from) and trying again.

If you still have issues once you've factored that out, I'd suggest making a minimal example repo to reproduce the issue and posting back here.