Add beforeRunners/afterRunners hooks for running setup that only needs to happen once per launcher
See original GitHub issueWhen shardTestFiles is true, everything set in the protractor config file gets sandboxed to the single testfile/thread being run, and methods such as onPrepare and onComplete get called at the beginning of each testfile/thread as opposed to before and after all testfiles/threads are run. This means there’s no way for test files to communicate to each other via global variables initialized in onPrepare, as well as the ability to chain custom properties onto the global browser object and use them across testfiles.
I set up a simple test. Here’s the pseudo code:
// in protractor config...
onPrepare: function(){
global.myGlobal = {};
}
onComplete: function() {
console.log(myGlobal);
},
// In foo.js...
myGlobal.foo = “fooValue”;
// In bar.js...
myGlobal.bar = “barValue”;
With shardTestFiles:false
, the console outputs
{ foo: fooValue, bar:barValue };
When shardTestFiles:true
, the console outputs
PID: 26780 (capability: firefox #1a)
Specs: testing/bar.js
{ bar: 'barValue’ }
[launcher] 1 instance(s) of WebDriver still running
------------------------------------
PID: 26722 (capability: firefox #1b)
Specs: testing/foo.js
{ foo: 'fooValue’ }
Seems like you could have launcher manage the protractor config as opposed to delegating it to the threads.
Issue Analytics
- State:
- Created 9 years ago
- Comments:14 (7 by maintainers)
Top GitHub Comments
let me put it this way , I need a variable to be available across multiple spec files and updates done by one spec file should be available for next spec file ? I have tried using global.variable , protractor.variable and browser.params but nothing seems to be working. Updated value is not available .
Protractor doesn’t have any special tools for cross process communication, but you could always try something like dnode