Adds test for browserify

This commit adds tests to make sure that the browserify bundle will work in the dist file of clipboard.js

This commit adds the mocha and chai modules, since karma doesn't work well with node only tests.

Also splited tests tasks in package.json and updated .gitignore
This commit is contained in:
Mauricio Soares 2015-09-29 16:44:45 -03:00 committed by Zeno Rocha
parent 623614a4e0
commit 4534fc4ca0
4 changed files with 26 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
npm-debug.log
bower_components
node_modules

View File

@ -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']

View File

@ -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"
}
}

11
test/node.js Normal file
View File

@ -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();
});
});
});