Skip to content

Commit

Permalink
Save the generated capabilities by browser between tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chinleung committed Feb 18, 2020
1 parent 2c29718 commit fecdec1
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/RunsOnBrowserStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ trait RunsOnBrowserStack
*/
protected static $connection;

/**
* The BrowserStack capabitities.
*
* @var array
*/
protected static $capabilities = [];

/**
* Update the BrowserStack status if the test has run on BrowserStack
* and close the current session if the user wants one test per session.
Expand Down Expand Up @@ -166,15 +173,21 @@ protected function detectOs(string $slug): array
*/
protected function capabilitiesForBrowserStack(): array
{
return array_merge(
[
'project' => $this->getProjectName(),
'build' => $this->getBuildName(),
'name' => $this->getSessionName(),
],
Arr::dot(config('browserstack.capabilities')),
$this->browserCapabilities()
);
$slug = $this->getBrowserSlug();

if (! isset(static::$capabilities[$slug])) {
static::$capabilities[$slug] = array_merge(
[
'project' => $this->getProjectName(),
'build' => $this->getBuildName(),
'name' => $this->getSessionName(),
],
Arr::dot(config('browserstack.capabilities')),
$this->browserCapabilities()
);
}

return static::$capabilities[$slug];
}

/**
Expand Down

0 comments on commit fecdec1

Please sign in to comment.