-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add visual regression testing (#132)
* add basic visual regression testing * store test cases in json array this will make it easier to test URLs with ?query=params * Run the tests in CI * add a test case for FTB style with long text * purposely break the build * Revert "purposely break the build" This reverts commit 6b0d8d7.
- Loading branch information
Showing
14 changed files
with
163 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
* text eol=lf | ||
* text eol=lf | ||
*.png binary |
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
/target | ||
ra-*.log | ||
rls*.log | ||
visual_regression_testing/diffs | ||
visual_regression_testing/node_modules | ||
visual_regression_testing/test_images |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
rm -rf test_images | ||
mkdir -p test_images | ||
|
||
rm -rf diffs | ||
mkdir -p diffs | ||
|
||
readarray -t test_cases < <(jq -c '.[]' test_cases.json) | ||
|
||
# from this point on, continue even if something fails | ||
# we want to continue testing further reference_images, even if one fails | ||
set +e | ||
|
||
exitcode=0 | ||
for test_case in "${test_cases[@]}"; do | ||
url=$(jq -r '.url' <<< "$test_case") | ||
filename=$(jq -r '.filename' <<< "$test_case") | ||
echo "Testing: $filename"; | ||
curl "$url" --silent -o "test_images/$filename" | ||
if ./node_modules/.bin/pixelmatch "test_images/$filename" "reference_images/$filename" "diffs/$filename"; then | ||
# if the images were exactly the same, discard the diff | ||
rm "diffs/$filename" | ||
else | ||
# one or more images has failed | ||
exitcode=1 | ||
fi | ||
echo "" | ||
done | ||
|
||
exit $exitcode |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"private": true, | ||
"dependencies": { | ||
"pixelmatch": "^5.3.0" | ||
} | ||
} |
Binary file added
BIN
+1.34 KB
...ffffjfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff-orange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.71 KB
visual_regression_testing/reference_images/build-passing-brightgreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[ | ||
{ | ||
"url": "http://localhost:3001/badge/build-passing-brightgreen.png", | ||
"filename": "build-passing-brightgreen.png" | ||
}, | ||
{ | ||
"url": "http://localhost:3001/badge/emoji-%E2%9D%A4%EF%B8%8F-blue.png", | ||
"filename": "emoji-❤️-blue.png" | ||
}, | ||
{ | ||
"url": "http://localhost:3001/badge/emoji-%F0%9F%87%B3%F0%9F%87%B4-blue.png", | ||
"filename": "emoji-🇳🇴-blue.png" | ||
}, | ||
{ | ||
"url": "http://localhost:3001/badge/emoji-%F0%9F%91%8D-blue.png", | ||
"filename": "emoji-👍-blue.png" | ||
}, | ||
{ | ||
"url": "http://localhost:3001/badge/emoji-%F0%9F%99%82-blue.png", | ||
"filename": "emoji-🙂-blue.png" | ||
}, | ||
{ | ||
"url": "http://localhost:3001/badge/%E3%83%A9%E3%83%99%E3%83%AB-%E3%83%A1%E3%83%83%E3%82%BB%E3%83%BC%E3%82%B8-lightgrey.png", | ||
"filename": "ラベル-メッセージ-lightgrey.png" | ||
}, | ||
{ | ||
"url": "http://localhost:3001/badge/foo-barfffffffffffffffffffffffffffffffffffffjfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff-orange.png?style=for-the-badge", | ||
"filename": "FTB-foo-barfffffffffffffffffffffffffffffffffffffjfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff-orange.png" | ||
} | ||
] |