From 82bea4c241648878d0c9e1d7a7cfdef1f0177b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Fri, 5 Jun 2015 16:57:56 +0200 Subject: [PATCH] integrate jest - not working yet though --- gulpfile.js | 41 ++++++++++++++++++++---- js/components/edition.js | 6 ++-- js/utils/__tests__/general_utils-test.js | 9 ++++++ package.json | 6 ++-- 4 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 js/utils/__tests__/general_utils-test.js diff --git a/gulpfile.js b/gulpfile.js index 6e5697bb..8de1b6eb 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -15,6 +15,7 @@ var sass = require('gulp-sass'); var concat = require('gulp-concat'); var _ = require('lodash'); var eslint = require('gulp-eslint'); +var jest = require('gulp-jest'); var config = { bootstrapDir: './node_modules/bootstrap-sass' @@ -24,14 +25,14 @@ gulp.task('build', function() { bundle(false); }); -gulp.task('serve', ['browser-sync', 'lint:watch', 'sass', 'sass:watch', 'copy'], function() { +gulp.task('serve', ['browser-sync', 'lint:watch', 'sass', 'sass:watch', 'copy', 'jest:watch'], function() { bundle(true); }); gulp.task('browser-sync', function() { browserSync({ server: { - baseDir: "." + baseDir: '.' }, port: process.env.PORT || 3000 }); @@ -44,7 +45,8 @@ gulp.task('sass', function () { includePaths: [ config.bootstrapDir + '/assets/stylesheets' ] - }).on('error', sass.logError)) + }) + .on('error', sass.logError)) .pipe(sourcemaps.write('./maps')) .pipe(gulp.dest('./build/css')) .pipe(browserSync.stream());; @@ -84,9 +86,34 @@ gulp.task('lint:watch', function () { gulp.watch('js/**/*.js', ['lint']); }); +gulp.task('jest', function () { + return gulp.src('__tests__').pipe(jest({ + scriptPreprocessor: "./node_modules/babel-jest", + testDirectoryName: '__tests__', + testPathIgnorePatterns: [ + 'node_modules', + 'spec/support' + ], + testFileExtensions: [ + 'es6', + 'js' + ], + moduleFileExtensions: [ + 'js', + 'json', + 'react', + 'es6' + ] + }) + .on('error', console.error)); +}); + +gulp.task('jest:watch', function () { + gulp.watch('__tests__', ['jest']); +}); + function bundle(watch) { var bro; - if (watch) { bro = watchify(browserify('./js/app.js', // Assigning debug to have sourcemaps @@ -101,11 +128,11 @@ function bundle(watch) { debug: true }); } - + bro.transform(babelify.configure({ compact: false })); - + function rebundle(bundler, watch) { return bundler.bundle() .on('error', notify.onError('Error: <%= error.message %>')) @@ -118,6 +145,6 @@ function bundle(watch) { .pipe(gulp.dest('./build')) .pipe(browserSync.stream()); } - + return rebundle(bro); } \ No newline at end of file diff --git a/js/components/edition.js b/js/components/edition.js index 8574b3dc..4e7abd4e 100644 --- a/js/components/edition.js +++ b/js/components/edition.js @@ -63,14 +63,14 @@ let Edition = React.createClass({ 0}> - 0}> - @@ -89,7 +89,7 @@ let Edition = React.createClass({ -