diff --git a/.gitignore b/.gitignore index 7bf6eb1..81ed6d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +npm-debug.log bower_components node_modules diff --git a/karma.conf.js b/karma.conf.js index e9f0673..954650c 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -10,6 +10,8 @@ module.exports = function(karma) { './node_modules/phantomjs-polyfill/bind-polyfill.js' ], + exclude: ['test/node.js'], + preprocessors: { 'src/**/*.js' : ['browserify'], 'test/**/*.js': ['browserify'] diff --git a/package.json b/package.json index 0a738cc..62d2e0d 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,14 @@ "main": "dist/clipboard.js", "browser": "src/clipboard.js", "browserify": { - "transform": [["babelify", { - "loose": "all" - }]] + "transform": [ + [ + "babelify", + { + "loose": "all" + } + ] + ] }, "license": "MIT", "keywords": [ @@ -29,6 +34,7 @@ "karma-mocha": "^0.2.0", "karma-phantomjs-launcher": "^0.2.1", "karma-sinon": "^1.0.4", + "mocha": "^2.3.3", "phantomjs-polyfill": "0.0.1", "uglify": "^0.1.5" }, @@ -36,6 +42,8 @@ "publish": "npm run build && npm run minify", "build": "browserify src/clipboard.js -s Clipboard -o dist/clipboard.js", "minify": "uglify -s dist/clipboard.js -o dist/clipboard.min.js", - "test": "karma start --single-run" + "test": "npm run mocha | npm run karma", + "karma": "karma start --single-run", + "mocha": "mocha test/node.js" } } diff --git a/test/node.js b/test/node.js new file mode 100644 index 0000000..ce0497c --- /dev/null +++ b/test/node.js @@ -0,0 +1,11 @@ +var assert = require('chai').assert; +var browserify = require('browserify'); + +describe('Node', function() { + it('should import the lib in a commonjs env without babel', function(done) { + browserify('./dist/clipboard.js').bundle(function(err) { + assert.equal(err, null); + done(); + }); + }); +});