From d98973c21f2fb7da55ec22bb4e45e996005c6c86 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Wed, 13 Apr 2016 12:14:12 -0400 Subject: [PATCH] Handle fatal errors in unit tests Due to the way our unit tests are run, a fatal error in the API code that causes the node process to quit with an error will not be picked up by `tap-dot`, and the unit tests will still return a passing status code. This is due to the way status codes from pipes are handled by default. Fortunately, there is an ["unofficial bash strict mode"](http://redsymbol.net/articles/unofficial-bash-strict-mode/) that helps fix this sort of thing, and by running our unit tests with a few tweaks we can ensure that any failure in the unit tests is captured. --- bin/units | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100755 bin/units diff --git a/bin/units b/bin/units new file mode 100755 index 00000000..b011e2ee --- /dev/null +++ b/bin/units @@ -0,0 +1,5 @@ +#!/bin/bash + +set -euo pipefail + +node test/unit/run.js | ./node_modules/.bin/tap-dot diff --git a/package.json b/package.json index f54db70c..0c0cc1f7 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "scripts": { "start": "node index.js", "test": "npm run unit", - "unit": "node test/unit/run.js | tap-dot", + "unit": "./bin/units", "ciao": "node node_modules/ciao/bin/ciao -c test/ciao.json test/ciao", "coverage": "node_modules/.bin/istanbul cover test/unit/run.js", "audit": "npm shrinkwrap; node node_modules/nsp/bin/nspCLI.js audit-shrinkwrap; rm npm-shrinkwrap.json;",