Skip to content

Instantly share code, notes, and snippets.

@anderssonjohan
Last active February 2, 2016 13:35
Show Gist options
  • Save anderssonjohan/1f8574844fbdd18c6431 to your computer and use it in GitHub Desktop.
Save anderssonjohan/1f8574844fbdd18c6431 to your computer and use it in GitHub Desktop.
Hack to send xUnit test result to the OSX notification center when having a running karma-osx-reporter
#!/usr/bin/env bash
# Use this to hijack the karma-osx-reporter web service listening to localhost:1337 to send
# xUnit result to the OSX notification center.
# See https://github.com/petrbela/karma-osx-reporter for output.
#
# Usage: ./report-osx-notifier.sh <path to xunit report.xml>
#
message=`grep "assembly" $1 | sed -e 's/[=\"]/ /g' | tr -s ' ' | grep -o "total[^>]*"`
method="pass"
if [ -z "$(echo $message | grep 'failed 0')" ]; then
method="fail"
fi
url="http://localhost:1337/$method?title=xUnit&message=$message"
url="${url// /%20}"
curl -s "$url" > /dev/null
{
"scripts": {
"api-test:watch": "cd api && cross-env ASPNET_ENV=Development dnx-watch test", // dnx command in api/project.json: "test": "xunit.runner.dnx -xml report.xml"
"api-test:osxnotify": "chokidar api/report.xml -c './api/report-osx-notifier.sh ./api/report.xml'",
"brunch-test:watch": "cd brunch && npm run karma",
"test:watch": "concurrent --kill-others -p command \"npm run api-test:watch\" \"npm run brunch-test:watch\" \"npm run api-test:osxnotify\"",
"test": "npm run api-test && npm run brunch-test",
},
"devDependencies": {
"chokidar-cli": "^1.2.0",
"concurrently": "^1.0.0",
"cross-env": "^1.0.7"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment