You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can reuse the usual const/let variable from test number 1, in test number 2the
Steps to reproduce
No response
Sample test
@a
Scenario: Set'test'variableGivenIsetthe"test"valuetothetestvariableWhenIlogthetestvariable
@a
Scenario: Log'test'variableWhenIlogthetestvariableconst{ Given }=require("@cucumber/cucumber")lettestGiven(/^I set the "(.*?)" value to the test variable$/,(value)=>{test=value})Given(/^I log the test variable$/,()=>{console.log(test)})
Command to run
npx nightwatch ./test
Verbose Output
info: Running the Scenario: Set 'test' variable
..STEP 1: Given I set the "test" value to the t
est variable
.STEP 2: When I log the test variable
test
info: Running the Scenario: Log 'test' variable
..STEP 1: When I log the test variable
test
Nightwatch Configuration
No response
Nightwatch.js Version
3.3.2
Node Version
18.21.0
Browser
No response
Operating System
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered:
Well, that's just how JavaScript (or any programming language for that matter) works... since test is declared in global scope (in the context of the file), it will be accessible in all the functions declared or called in that file. And if one such function changes its value, it will be changed for all the functions that access it afterwards.
What you can do is reset the variable test manually at the end or start of each test, but the function to reset should be mentioned in the same file so that it can access the test variable.
@garg3133 But it worked in another way in the 2.2.3 version. It also seems to me that it violated the principle where each test should be completely independent
Description of the bug/issue
I can reuse the usual const/let variable from test number 1, in test number 2the
Steps to reproduce
No response
Sample test
Command to run
Verbose Output
Nightwatch Configuration
No response
Nightwatch.js Version
3.3.2
Node Version
18.21.0
Browser
No response
Operating System
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: