title: WebdriverIO JS how to only run code block if tests are running on Browserstack
body: <p>I have some code in my hooks that runs while were running tests in Browserstack to update test results etc.</p>
  <p>The line of code in question:</p>
  <p><code>global.driver.execute(`browserstack_executor: ${JSON.stringify(result)}`)</code></p>
  <p>The problem with having it running in the hooks is that it'll run even if we're running the tests locally.</p>
  <p>This produces the error (which makes sense):</p>
  <p><strong>ERROR webdriver: Request failed with status 405 due to unknown method: Method is not implemented</strong></p>
  <p>Obviously we don't want this running at all when we're running the tests locally, so I wrapped it in a try catch. The issue is that the error is actually being thrown after the try catch so doesn't actually suppress the error at all.</p>
  <p>I want to try and wrap this in an if statement that says &quot;If we're running tests in Browserstack then...&quot; however I'm unsure how to write this, or if anything like this exists at all.</p>
  <p>Any help or other suggestions would be appreciated!</p>