diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..c6d53e29 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,5 @@ +. +gulpfile.js +node_modules + +js/**/__tests__ \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 8de1b6eb..0bd15054 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,7 @@ 'use strict'; +require("harmonize")(); + var gulp = require('gulp'); var gulpif = require('gulp-if'); var sourcemaps = require('gulp-sourcemaps'); @@ -15,20 +17,48 @@ var sass = require('gulp-sass'); var concat = require('gulp-concat'); var _ = require('lodash'); var eslint = require('gulp-eslint'); -var jest = require('gulp-jest'); +var jest = require('jest-cli'); var config = { - bootstrapDir: './node_modules/bootstrap-sass' + bootstrapDir: './node_modules/bootstrap-sass', + jestOptions: { + rootDir: 'js', + scriptPreprocessor: '../node_modules/babel-jest', + testFileExtensions: [ + 'es6', + 'js' + ], + unmockedModulePathPatterns: [ + '/node_modules/react', + '/node_modules/react-tools' + ], + moduleFileExtensions: [ + 'js', + 'json', + 'react', + 'es6' + ] + } }; gulp.task('build', function() { bundle(false); }); -gulp.task('serve', ['browser-sync', 'lint:watch', 'sass', 'sass:watch', 'copy', 'jest:watch'], function() { +gulp.task('serve', ['browser-sync', 'jest:watch', 'lint:watch', 'sass', 'sass:watch', 'copy'], function() { bundle(true); }); +gulp.task('jest', function(done) { + jest.runCLI({ config : config.jestOptions }, ".", function() { + done(); + }); +}); + +gulp.task('jest:watch', function(done) { + gulp.watch([ config.jestOptions.rootDir + "/**/*.js" ], [ 'jest' ]); +}); + gulp.task('browser-sync', function() { browserSync({ server: { @@ -76,42 +106,15 @@ gulp.task('lint', function () { .pipe(eslint()) // eslint.format() outputs the lint results to the console. // Alternatively use eslint.formatEach() (see Docs). - .pipe(eslint.format()) + .pipe(eslint.format()); // To have the process exit with an error code (1) on // lint error, return the stream and pipe to failOnError last. - .pipe(eslint.failOnError()); }); 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) { diff --git a/js/utils/__tests__/general_utils-test.js b/js/utils/__tests__/general_utils_test.js similarity index 70% rename from js/utils/__tests__/general_utils-test.js rename to js/utils/__tests__/general_utils_test.js index 6373ec85..5edb50df 100644 --- a/js/utils/__tests__/general_utils-test.js +++ b/js/utils/__tests__/general_utils_test.js @@ -1,9 +1,9 @@ -jest.autoMockOff(); +jest.dontMock('../general_utils'); import * as GeneralUtils from '../general_utils'; describe('GeneralUtils', () => { it('should do something', () => { - console.log('asdasdasd'); + return false; }); }); \ No newline at end of file diff --git a/package.json b/package.json index 4f3265e1..d7922e14 100644 --- a/package.json +++ b/package.json @@ -23,11 +23,11 @@ "gulp-concat": "^2.5.2", "gulp-eslint": "^0.13.2", "gulp-if": "^1.2.5", - "gulp-jest": "^0.4.0", "gulp-notify": "^2.2.0", "gulp-sass": "^2.0.1", "gulp-sourcemaps": "^1.5.2", "gulp-util": "^3.0.4", + "harmonize": "^1.4.2", "jest-cli": "^0.4.0", "lodash": "^3.9.3", "reactify": "^1.1.0", @@ -47,13 +47,5 @@ "react-router": "^0.13.3", "shmui": "^0.1.0", "uglifyjs": "^2.4.10" - }, - "jest": { - "scriptPreprocessor": "node_modules/babel-jest", - "unmockedModulePathPatterns": [ - "/node_modules/react", - "/node_modules/alt", - "/js/alt.js" - ] } }