subsecondtdd / todo-subsecond

Tiny web app to demonstrate subsecond full-stack acceptance tests with Node.js and Cucumber
MIT License
207 stars 31 forks source link

Browserstack fails on first attempt #6

Open joshski opened 6 years ago

joshski commented 6 years ago

The first time I run ./features/run/browserstack-memory I see an error like this

WebDriverError: [browserstack.local] is set to true but local testing through BrowserStack is not connected.

...however the browserstack-local-nodejs package has started a local tunnel (and left it running, which seems broken too!):

> ps -x | grep browserstack
46847 ??         0:00.74 /Users/me/.browserstack/BrowserStackLocal --daemon start --log-file /Users/me/projects/todo-subsecond/local.log --key <redacted> -daemonInstance

The second run passes. So it looks to me like browserstack-local calls it's callback before it's actually ready, or something.

joshski commented 6 years ago

Looking at the code, there seems to be a commented out bit that waits for evidence that the tunnel is actually started

arjunjh10 commented 6 years ago

I face this issue too. Getting around it locally by re-running the test is fine. But this has become a bigger problem for me since now I am trying to use Browserstack Local on TeamCity servers.

arjunjh10 commented 6 years ago

My work around was to use Pify. We use Typescript and async/awaits in our code.

 if (capabilities['browserstack.local']) {
      process.env.TARGET_URL = process.env.TEST_URL;
      await pify(bsLocal.start.bind(bsLocal))({key: accessKey, verbose: 'true'});
      info('Local session started, launching driver now');
    } else {
      // process.env.TARGET_URL = 'URL';
      info('Normal Session Started');
    }