Last active
June 8, 2017 19:53
-
-
Save dan2k3k4/ca1e2fc7f22f0b0f851305dbb625f404 to your computer and use it in GitHub Desktop.
Revisions
-
dan2k3k4 revised this gist
Jun 8, 2017 . 1 changed file with 3 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,8 +22,7 @@ if (isset($matches[1])) { $url = trim($matches[1]); // Generate screenshot of frontpage exec(sprintf('/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --disable-gpu --screenshot --window-size=1920,1080 http://%s', $url)); // Move screenshot.png to tests-visual/ directory if (is_file('screenshot.png')) { @@ -32,8 +31,8 @@ if (isset($matches[1])) { // Lets diff our screenshot and open that too if (is_file('tests-visual/screenshot-old.png')) { exec('compare tests-visual/screenshot-old.png tests-visual/screenshot.png tests-visual/diff.png'); exec('open tests-visual/diff.png'); } } -
dan2k3k4 created this gist
Jun 8, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ #!/usr/local/bin/php <?php /** * Just a quick script for Headless Chrome testing */ if (!is_dir('tests-visual')) { mkdir('tests-visual', 0777); } // Rename older screenshot to screenshot-old if (is_file('tests-visual/screenshot.png')) { rename('tests-visual/screenshot.png', 'tests-visual/screenshot-old.png'); } // Get URL to test $pattern = '/hostname: &hostname ([^ ]+)/'; preg_match($pattern, file_get_contents('docker-compose.yml'), $matches); if (isset($matches[1])) { // We can now test our app $url = trim($matches[1]); // Generate screenshot of frontpage $headlessChrome = sprintf('/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --disable-gpu --screenshot --window-size=1920,1080 http://%s', $url); exec($headlessChrome, $output); // Move screenshot.png to tests-visual/ directory if (is_file('screenshot.png')) { rename('screenshot.png', 'tests-visual/screenshot.png'); } // Lets diff our screenshot and open that too if (is_file('tests-visual/screenshot-old.png')) { exec('compare tests-visual/screenshot-old.png tests-visual/screenshot.png -compose src tests-visual/diff.png', $output); exec('open tests-visual/diff.png', $output); } }