Skip to content

Instantly share code, notes, and snippets.

@whymarrh
Created August 3, 2013 21:36
Show Gist options
  • Save whymarrh/6148069 to your computer and use it in GitHub Desktop.
Save whymarrh/6148069 to your computer and use it in GitHub Desktop.
Run nature/pa11y against an array of app routes.
#!/usr/bin/env bash
# servers
jeeves="localhost:7211"
alfred="localhost:7212"
abyss="/dev/null"
cd "public"
php -S "$jeeves" &> "$abyss" &
z=$!
cd ..
date=$(date)
folder=$(echo -n "$date" | openssl md5)
tmp=".tmp"
www="$tmp/$folder"
[[ -d "$tmp" ]] && echo "$tmp exists" || mkdir "$tmp"
[[ -d "$www" ]] && echo "$www exists" || mkdir "$www"
cd "$www"
php -S "$alfred" &> "$abyss" &
s=$!
cd ../..
end ()
{
rm -r "$tmp"
kill $z
kill $s
exit $1
}
sleep 1
cookies="$tmp/.cookies"
curl --silent \
--location \
--cookie-jar $cookies \
--cookie $cookies \
--data "email-address=jan%40foo.com&password=password&remember-me=0" \
"$jeeves/users/login" \
> "$abyss"
pa11y="node_modules/.bin/pa11y"
[[ -x $pa11y ]] || npm install pa11y
routes=(
# list of routes
)
for route in ${routes[@]}
do
echo "Running pa11y against route: $route"
curl --silent --location --cookie $cookies --cookie-jar $cookies "$jeeves$route" > "$www/index.html"
$pa11y $@ --config .pa11y.json --standard WCAG2AAA "$alfred" || end $?
done
end 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment