Skip to content

Commit d129434

Browse files
authored
fix: screenshot on error feature (#417)
* fix: screenshot on error feature * update changelog
1 parent 622613b commit d129434

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
1.0.1
5+
-----
6+
7+
* Fix storing screenshots in the wrong directory when `PANTHER_ERROR_SCREENSHOT_DIR` is enabled
8+
49
1.0.0
510
-----
611

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ The following environment variables can be set to change some Panther's behaviou
334334
* `PANTHER_WEB_SERVER_ROUTER`: to use a web server router script which is run at the start of each HTTP request
335335
* `PANTHER_EXTERNAL_BASE_URI`: to use an external web server (the PHP built-in web server will not be started)
336336
* `PANTHER_APP_ENV`: to override the `APP_ENV` variable passed to the web server running the PHP app
337-
* `PANTHER_ERROR_SCREENSHOT_DIR`: to set a base directory for your failure/error screenshots (e.g. `./screenshots`)
337+
* `PANTHER_ERROR_SCREENSHOT_DIR`: to set a base directory for your failure/error screenshots (e.g. `./var/error-screenshots`)
338338

339339
### Changing the Hostname and Port of the Built-in Web Server
340340

src/ServerExtension.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,14 @@ private static function reset(): void
8080

8181
private function takeScreenshots(string $type, string $test): void
8282
{
83-
if (!($_SERVER['PANTHER_SCREENSHOT_DIR'] ?? false)) {
83+
if (!($_SERVER['PANTHER_ERROR_SCREENSHOT_DIR'] ?? false)) {
8484
return;
8585
}
8686

8787
foreach (self::$registeredClients as $i => $client) {
88-
$client->takeScreenshot(sprintf('%s_%s_%s-%d.png',
89-
(new \DateTime())->format('Y-m-d_H-i-s'),
88+
$client->takeScreenshot(sprintf('%s/%s_%s_%s-%d.png',
89+
$_SERVER['PANTHER_ERROR_SCREENSHOT_DIR'],
90+
date('Y-m-d_H-i-s'),
9091
$type,
9192
strtr($test, ['\\' => '-', ':' => '_']),
9293
$i

0 commit comments

Comments
 (0)