Browse Source

Merge pull request #587 from braydonf/feature/karma

Tests: Add karma config and dependencies
patch-2
Manuel Aráoz 10 years ago
parent
commit
9e34dfe3dd
  1. 17
      .travis.yml
  2. 27
      gulpfile.js
  3. 13
      karma.conf.js
  4. 10
      package.json

17
.travis.yml

@ -1,11 +1,12 @@
language: node_js language: node_js
node_js: node_js:
- '0.10' - '0.10'
notifications: before_install:
hipchat: - npm install -g bower
rooms: - npm install -g grunt-cli
secure: p6IUoOsKoM7cEmUsYh9JV5XKpUSASXukGkiBxdPU+ELM1CgNT0PyUROXwgDvI0vjSBCJemNh5sqrEQWiT70PcR69rH1JQ6+mHZah4r6W1Ql0NuWibvsofLyCeTzW2nrptdx97Z4y65NiHsaaOo3F+BShTeBpmBAvRMNp/FLMjWU= - export DISPLAY=:99.0
template: - sh -e /etc/init.d/xvfb start
- '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message} (<a href="%{build_url}">Details</a>/<a href="%{compare_url}">Change view</a>)' install:
format: html - bower install
on_success: never - npm install

27
gulpfile.js

@ -33,12 +33,23 @@ function ignoreError() {
/* jshint ignore:end */ /* jshint ignore:end */
} }
function testMocha() { var testMocha = function() {
return gulp.src(tests).pipe(new mocha({reporter: 'spec'})); return gulp.src(tests).pipe(new mocha({
} reporter: 'spec'
}));
};
var testKarma = shell.task([
'./node_modules/karma/bin/karma start --single-run --browsers Firefox'
]);
gulp.task('test', testMocha); gulp.task('test', testMocha);
gulp.task('test-all', function(callback) {
runSequence(['test'], ['karma'], callback);
});
gulp.task('test-nofail', function() { gulp.task('test-nofail', function() {
return testMocha().on('error', ignoreError); return testMocha().on('error', ignoreError);
}); });
@ -55,6 +66,10 @@ gulp.task('watch:lint', function() {
return gulp.watch(alljs, ['lint']); return gulp.watch(alljs, ['lint']);
}); });
gulp.task('watch:browser', function() {
return gulp.watch(alljs, ['browser-all']);
});
gulp.task('coverage', shell.task(['istanbul cover _mocha -- --recursive'])); gulp.task('coverage', shell.task(['istanbul cover _mocha -- --recursive']));
gulp.task('jsdoc', function() { gulp.task('jsdoc', function() {
@ -85,6 +100,12 @@ gulp.task('browser-test', shell.task([
'find test/ -type f -name "*.js" | xargs browserify -o ./browser/tests.js' 'find test/ -type f -name "*.js" | xargs browserify -o ./browser/tests.js'
])); ]));
gulp.task('browser-all', function(callback) {
runSequence(['browser'], ['browser-test'], callback);
});
gulp.task('karma', testKarma);
gulp.task('minify', function() { gulp.task('minify', function() {
return gulp.src('dist/bitcore.js') return gulp.src('dist/bitcore.js')
.pipe(closureCompiler({ .pipe(closureCompiler({

13
karma.conf.js

@ -0,0 +1,13 @@
'use strict';
// karma.conf.js
module.exports = function(config) {
config.set({
frameworks: ['mocha'],
browsers: ['Chrome', 'Firefox'],
singleRun: true,
files: [
'browser/tests.js'
]
});
};

10
package.json

@ -6,9 +6,10 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"lint": "gulp lint", "lint": "gulp lint",
"test": "gulp test", "test": "gulp test-all",
"coverage": "gulp coverage", "coverage": "gulp coverage",
"build": "gulp" "build": "gulp",
"postinstall": "node_modules/gulp/bin/gulp.js browser-all"
}, },
"contributors": [ "contributors": [
{ {
@ -91,7 +92,10 @@
"gulp-shell": "^0.2.10", "gulp-shell": "^0.2.10",
"lodash": "^2.4.1", "lodash": "^2.4.1",
"mocha": "~2.0.1", "mocha": "~2.0.1",
"run-sequence": "^1.0.2" "run-sequence": "^1.0.2",
"karma": "^0.12.28",
"karma-mocha": "^0.1.9",
"karma-firefox-launcher": "^0.1.3"
}, },
"license": "MIT" "license": "MIT"
} }

Loading…
Cancel
Save