code coverage (#61)

* code coverage

* code cov to travis
diff --git a/.gitignore b/.gitignore
index b0e3907..4772e87 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,9 @@
 node_modules
 npm-debug.log
 .DS_Store
+coverage
+.nyc_output
+ecma5
+.DS_STORE
+package-lock.json
+coverage.lcov
diff --git a/.travis.yml b/.travis.yml
index 153a3f5..3c040bf 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,6 +19,4 @@
 script:
   - ./tools/travis/scancode.sh
   - cd $TRAVIS_BUILD_DIR
-  - ./tools/travis/unit.sh
-  - cd $TRAVIS_BUILD_DIR
-  - ./tools/travis/integration.sh
+  - ./tools/travis/build.sh
diff --git a/README.md b/README.md
index 0a30b64..36b4a19 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,7 @@
 
 [![Build Status](https://travis-ci.org/apache/incubator-openwhisk-client-js.svg?branch=master)](https://travis-ci.org/apache/incubator-openwhisk-client-js)
 [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)
+[![codecov](https://codecov.io/gh/apache/incubator-openwhisk-client-js/branch/master/graph/badge.svg)](https://codecov.io/gh/apache/incubator-openwhisk-client-js)
 
 JavaScript client library for the [Apache OpenWhisk](https://github.com/apache/incubator-openwhisk) platform.
 Provides a wrapper around the [OpenWhisk APIs](https://github.com/apache/incubator-openwhisk/blob/fb001afa237476eda0c0f6494ee92702e5986538/core/controller/src/main/resources/apiv1swagger.json) (Swagger JSON).
@@ -510,4 +511,19 @@
 ```
 ./test/integration/prepIntegrationTests.sh <your key in the form of ABCD:EFGH> <openwhisk instance hostname> <openwhisk namespace> <api gatewaytoken>
 ```  
-The `prepIntegrationTests.sh` script is designed to give you feedback if it detects a setting that is not correct on your machine. ex: `node 6 is not detected`
+The `prepIntegrationTests.sh` script is designed to give you feedback if it detects a setting that is not correct on your machine. ex: `node 6 or above is not detected`
+
+## Code-Coverage:
+
+You can customize how comprehensive the tests are over the code, and generate reports to view the results by using
+the provided `code-coverage` commands below.  
+
+**Note:** Ensure that you use guest credentials with the wsk CLI.  
+
+To compile down to ECMA5 run the following command:  
+1 `npm run code-coverage-build`  
+
+To generate combined reports of both the unit and integration tests, run the following command:  
+2 `npm run code-coverage-run`  
+
+The report is viewable under `/coverage`. Click **`/coverage/index.html`** to view the full report.  
diff --git a/package.json b/package.json
index c47cd13..e3cdec8 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,10 @@
   },
   "scripts": {
     "test": "ava test/unit",
-    "test-integration": "ava test/integration/*.test.js"
+    "test-integration": "ava test/integration/*.test.js",
+    "code-coverage-build": "babel --out-dir=ecma5 lib",
+    "code-coverage-run": "./tools/merge-coverage.sh",
+    "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov"
   },
   "repository": {
     "type": "git",
@@ -30,10 +33,33 @@
   "homepage": "https://github.com/openwhisk/openwhisk-client-js#readme",
   "devDependencies": {
     "ava": "^0.15.2",
+    "babel": "^6.23.0",
+    "babel-cli": "^6.24.1",
+    "codecov": "^2.3.0",
     "jszip": "^3.1.3",
+    "nyc": "^11.0.3",
     "proxyquire": "1.7.4"
   },
   "dependencies": {
     "request-promise": "^2.0.1"
+  },
+  "babel": {
+    "presets": [
+      "es2015"
+    ],
+    "plugins": [
+      "transform-runtime"
+    ],
+    "ignore": "test",
+    "env": {
+      "development": {
+        "sourceMaps": "inline"
+      }
+    }
+  },
+  "ava": {
+    "require": [
+      "babel-core/register"
+    ]
   }
 }
diff --git a/tools/merge-coverage.sh b/tools/merge-coverage.sh
new file mode 100755
index 0000000..03da3db
--- /dev/null
+++ b/tools/merge-coverage.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+runningEnv="$1"
+
+tempDir="coveragetemp"
+mkdir $tempDir
+mkdir $tempDir/unit
+mkdir $tempDir/integration
+
+#Create json coverage items for unit and integration tests
+node ./node_modules/nyc/bin/nyc.js ava test/unit
+unitstatus="$PIPESTATUS"
+mv .nyc_output/* $tempDir/unit
+
+node ./node_modules/nyc/bin/nyc.js ./test/integration/prepIntegrationTests.sh guest
+integrationstatus="$PIPESTATUS"
+mv .nyc_output/* $tempDir/integration
+
+#move merged json back and delete temporary folder
+cp -a $tempDir/unit/. .nyc_output
+cp -a $tempDir/integration/. .nyc_output
+rm -rf $tempDir
+
+# generate the HTML report from the merged results
+if [ "$runningEnv" == "travis" ] ; then
+  npm run coverage
+fi
+
+node ./node_modules/nyc/bin/nyc.js report --reporter=html
+
+
+if [ "$unitstatus" = "0" ] && [ "$integrationstatus" = "0" ] ; then
+    exit 0
+else
+    echo "one or more of either the unit tests or integration tests failed: unit status: $unitstatus; integration status: $integrationstatus;"
+    exit 1
+fi
diff --git a/tools/travis/integration.sh b/tools/travis/build.sh
similarity index 92%
rename from tools/travis/integration.sh
rename to tools/travis/build.sh
index 039355e..09028b4 100755
--- a/tools/travis/integration.sh
+++ b/tools/travis/build.sh
@@ -42,5 +42,6 @@
 
 # Test
 cd $ROOTDIR
-npm install
-./test/integration/prepIntegrationTests.sh guest
+npm install --dev
+npm run code-coverage-build
+npm run code-coverage-run travis
diff --git a/tools/travis/unit.sh b/tools/travis/unit.sh
deleted file mode 100755
index 078d9e6..0000000
--- a/tools/travis/unit.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-set -e
-SCRIPTDIR=$(cd $(dirname "$0") && pwd)
-ROOTDIR="$SCRIPTDIR/../.."
-
-cd $ROOTDIR
-npm install
-npm run test
-exit $PIPESTATUS