diff options
author | Aleksander Machniak <alec@alec.pl> | 2019-12-30 14:44:26 +0300 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2019-12-30 14:44:26 +0300 |
commit | 87304c29d17f2888aba7a029a8bef86b088b94f1 (patch) | |
tree | 59e287078d1facbe8633014557ed2a690861f1a8 /tests | |
parent | 53a111f8c336f550fe79a7c1c22918c5db25f8d5 (diff) |
Travis: Fix in-browser tests setup
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Browser/DuskTestCase.php | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/Browser/DuskTestCase.php b/tests/Browser/DuskTestCase.php index 0381a0b9c..ea7bbefb9 100644 --- a/tests/Browser/DuskTestCase.php +++ b/tests/Browser/DuskTestCase.php @@ -70,6 +70,11 @@ abstract class DuskTestCase extends TestCase Browser::$storeScreenshotsAt = __DIR__ . '/screenshots'; Browser::$storeConsoleLogAt = __DIR__ . '/console'; + // This folder must exist in case Browser will try to write logs to it + if (!is_dir(Browser::$storeConsoleLogAt)) { + mkdir(Browser::$storeConsoleLogAt, 0777, true); + } + // Purge screenshots from the last test run $pattern = sprintf('failure-%s_%s-*', str_replace("\\", '_', get_class($this)), @@ -77,7 +82,23 @@ abstract class DuskTestCase extends TestCase ); try { - $files = Finder::create()->files()->in(__DIR__ . '/screenshots')->name($pattern); + $files = Finder::create()->files()->in(Browser::$storeScreenshotsAt)->name($pattern); + foreach ($files as $file) { + @unlink($file->getRealPath()); + } + } + catch (\Symfony\Component\Finder\Exception\DirectoryNotFoundException $e) { + // ignore missing screenshots directory + } + + // Purge console logs from the last test run + $pattern = sprintf('%s_%s-*', + str_replace("\\", '_', get_class($this)), + $this->getName(false) + ); + + try { + $files = Finder::create()->files()->in(Browser::$storeConsoleLogAt)->name($pattern); foreach ($files as $file) { @unlink($file->getRealPath()); } |