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
The changes we make to browser.globals by default do not persist for the complete duration of the test run and are only available in the context of the test suite where the changes are made.
So, to allow users to have the changes made during the test run to persist till the end of the test run (even across test suites), we have persist_globals setting. And while this setting works great when running tests in serial mode, it is not obeyed in parallel mode.
Now, in parallel run, persisting changes to globals across test suites do not make any sense as the test suites will be running parallelly in different worker processes. But, if we make some changes to globals in the global before hook (which runs in the main process before individual test workers are created), those changes should ideally be persisted and sent to the individual test workers when they are created, if persist_globals setting is enabled.
Create a globals.js file and a sample test file shown below.
Run the test in parallel mode.
Sample test
// globals.jsletnewVar={};module.exports={newVar: newVar,before: ()=>{newVar['setting']='something';},};// test/sampleTest.jsdescribe('Ecosia.org Demo',function(){before(browser=>browser.navigateTo('https://www.ecosia.org/'));it('Demo test ecosia.org',asyncfunction(browser){console.log(browser.globals.newVar);// will be empty object});});
Command to run
npx nightwatch ./test
Verbose Output
No response
Nightwatch Configuration
No response
Nightwatch.js Version
3.3.7
Node Version
No response
Browser
No response
Operating System
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered:
Hi @garg3133, As we already pass settings to individual workers, I wonder if we can add the globals_path for globals.js to settings inorder to pass globals, whenever the persist_globals setting is enabled ?
Description of the bug/issue
The changes we make to
browser.globals
by default do not persist for the complete duration of the test run and are only available in the context of the test suite where the changes are made.So, to allow users to have the changes made during the test run to persist till the end of the test run (even across test suites), we have
persist_globals
setting. And while this setting works great when running tests in serial mode, it is not obeyed in parallel mode.Now, in parallel run, persisting changes to globals across test suites do not make any sense as the test suites will be running parallelly in different worker processes. But, if we make some changes to globals in the global
before
hook (which runs in the main process before individual test workers are created), those changes should ideally be persisted and sent to the individual test workers when they are created, ifpersist_globals
setting is enabled.More context: https://discord.com/channels/618399631038218240/1194196887650185237/1194196887650185237
Previous work and discussion on passing settings to individual workers: #3791 (comment)
(Though instead of passing settings, we only need to pass the globals this time.)
Steps to reproduce
globals.js
file and a sample test file shown below.Sample test
Command to run
Verbose Output
No response
Nightwatch Configuration
No response
Nightwatch.js Version
3.3.7
Node Version
No response
Browser
No response
Operating System
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: