From 30f26e554ddc8aa7e1825b70a171039b68f9737c Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 7 Jul 2014 16:54:08 -0700 Subject: [PATCH] setup istanbul MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit i’m manually instrumenting the code and requiring it, per what is discussed here: https://github.com/karma-runner/karma-coverage/issues/16 --- .gitignore | 1 + Gruntfile.js | 13 ++++++++++--- karma.conf.js | 4 ++-- package.json | 5 ++++- test/.jshintrc | 1 + test/common.js | 3 +++ test/spec/client.js | 26 ++++++++++++++++++++++++++ test/spec/lib.js | 6 +++--- 8 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 test/common.js create mode 100644 test/spec/client.js diff --git a/.gitignore b/.gitignore index 6cfce1c..1be9258 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ npm-debug.log *.iml .idea .DS_Store +.tmp diff --git a/Gruntfile.js b/Gruntfile.js index 48ee7ba..8be1dac 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -23,11 +23,18 @@ module.exports = function (grunt) { } } }, - + clean: ['./.tmp'], + instrument: { + files: 'lib/**/*.js', + options: { + lazy: true, + basePath: '.tmp/instrumented/' + } + }, watch: { js:{ - files: ['lib/**/*.js','test/**/*.js'], - tasks: ['karma:liveunit:run','build'] + files: ['lib/**/*.js','test/spec/**/*.js'], + tasks: ['clean','instrument','karma:liveunit:run'] } }, // Test settings diff --git a/karma.conf.js b/karma.conf.js index c464fb0..3107237 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -47,10 +47,10 @@ module.exports = function(config) { preprocessors: { - 'test/**/*.js': ['browserify'] + 'test/spec/*.js': ['browserify'] }, - reporters: ['progress'], + reporters: ['progress','coverage'], // Continuous Integration mode diff --git a/package.json b/package.json index 99e0228..7e91d73 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,10 @@ "karma-chrome-launcher": "^0.1.4", "karma-browserify": "^0.2.1", "chai": "^1.9.1", - "karma-chai": "^0.1.0" + "karma-chai": "^0.1.0", + "karma-coverage": "^0.2.4", + "grunt-istanbul": "^0.3.0", + "grunt-contrib-clean": "^0.5.0" }, "dependencies": { "Base64": "^0.3.0" diff --git a/test/.jshintrc b/test/.jshintrc index cb72c2b..5f79065 100644 --- a/test/.jshintrc +++ b/test/.jshintrc @@ -22,6 +22,7 @@ "globals": { "after": false, "afterEach": false, + "assert": false, "angular": false, "before": false, "beforeEach": false, diff --git a/test/common.js b/test/common.js new file mode 100644 index 0000000..0a72bd2 --- /dev/null +++ b/test/common.js @@ -0,0 +1,3 @@ +module.exports = { + stormpath: require('../.tmp/instrumented/lib') +}; \ No newline at end of file diff --git a/test/spec/client.js b/test/spec/client.js new file mode 100644 index 0000000..33d2c24 --- /dev/null +++ b/test/spec/client.js @@ -0,0 +1,26 @@ +'use strict'; + +var stormpathJs = require('../common').stormpath; + +describe('Client', function () { + + + describe('instantiation', function () { + describe('without a JWT in the url', function () { + var result; + before(function(done){ + new stormpathJs.Client(function(err,res){ + result = [err,res]; + done(); + }); + }); + it('should err because jwt was not found',function(){ + assert.instanceOf(result[0],Error); + }); + }); + + + }); + + +}); \ No newline at end of file diff --git a/test/spec/lib.js b/test/spec/lib.js index 49e1f1c..b41e457 100644 --- a/test/spec/lib.js +++ b/test/spec/lib.js @@ -1,11 +1,11 @@ 'use strict'; -describe('lib', function () { +var stormpath = require('../common').stormpath; - var stormpath; +describe('lib', function () { it('should be require-able',function(){ - stormpath = require('../../'); + stormpath = require('../../.tmp/instrumented/lib'); }); it('should be an object', function () {