question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add beforeRunners/afterRunners hooks for running setup that only needs to happen once per launcher

See original GitHub issue

When 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:closed
  • Created 9 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
ProtHelpcommented, Dec 18, 2015

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 .

0reactions
sjelincommented, Dec 18, 2015

Protractor doesn’t have any special tools for cross process communication, but you could always try something like dnode

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Install and Use Advanced Hook Launchers
Navigate to your Apex server panel, then log in. · Scroll down to the Game File section, then open the dropdown. · Ensure...
Read more >
Add hooks support to configuration file · Issue #2507 - GitHub
I currently have a setup which uses nodemon to run Karma once . ... during said tests (karma-runner/karma-phantomjs-launcher#19 (comment)).
Read more >
Custom Services - WebdriverIO
Services have access to all the same hooks available in the wdio.conf.js . ... are only executed once per test run, and a...
Read more >
How To Add Grappling Hooks to Minecraft 1.15.2! - YouTube
You now know exactly how to download and install Advanced Hook Launchers in Minecraft 1.15.2. If you do have any issues getting grappling ......
Read more >
How to add a hook to the Vertx Launcher - Stack Overflow
I would like to collect metrics with Vert.x Micrometer Metrics, so I need to set proper options to VertxOptions. I run Vertx with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found