Skip to content

Instantly share code, notes, and snippets.

@dgrebb
Last active December 31, 2023 07:16
Show Gist options
  • Save dgrebb/cbd4d5271c2cd718923bb6cb06f68766 to your computer and use it in GitHub Desktop.
Save dgrebb/cbd4d5271c2cd718923bb6cb06f68766 to your computer and use it in GitHub Desktop.
JSON file diff test for GitHub Actions with property filtering of known dynamic property values
#!/bin/bash
# Filter known dynamic timestamped `test`, `testLog`, and `diffImage` properties
# Then compare results, and `exit 1` if newly generated report.json is different.
diff -q <(jq -S ". | del(.tests[].pair.test, .tests[].pair.testLog, .tests[].pair.diffImage)" test/__fixtures__/sanity-test.json) \
<(jq -S ". | del(.tests[].pair.test, .tests[].pair.testLog, .tests[].pair.diffImage)" test/configs/backstop_data/bitmaps_test/**/report.json)
if [[ $? == "0" ]]; then
exit 0
else
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment