1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

finish integrating jest testing suite

This commit is contained in:
Tim Daubenschütz 2015-06-08 09:53:14 +02:00
parent 82bea4c241
commit b1973d3a64
4 changed files with 42 additions and 42 deletions

5
.eslintignore Normal file
View File

@ -0,0 +1,5 @@
.
gulpfile.js
node_modules
js/**/__tests__

View File

@ -1,5 +1,7 @@
'use strict'; 'use strict';
require("harmonize")();
var gulp = require('gulp'); var gulp = require('gulp');
var gulpif = require('gulp-if'); var gulpif = require('gulp-if');
var sourcemaps = require('gulp-sourcemaps'); var sourcemaps = require('gulp-sourcemaps');
@ -15,20 +17,48 @@ var sass = require('gulp-sass');
var concat = require('gulp-concat'); var concat = require('gulp-concat');
var _ = require('lodash'); var _ = require('lodash');
var eslint = require('gulp-eslint'); var eslint = require('gulp-eslint');
var jest = require('gulp-jest'); var jest = require('jest-cli');
var config = { var config = {
bootstrapDir: './node_modules/bootstrap-sass' bootstrapDir: './node_modules/bootstrap-sass',
jestOptions: {
rootDir: 'js',
scriptPreprocessor: '../node_modules/babel-jest',
testFileExtensions: [
'es6',
'js'
],
unmockedModulePathPatterns: [
'<rootDir>/node_modules/react',
'<rootDir>/node_modules/react-tools'
],
moduleFileExtensions: [
'js',
'json',
'react',
'es6'
]
}
}; };
gulp.task('build', function() { gulp.task('build', function() {
bundle(false); 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); 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() { gulp.task('browser-sync', function() {
browserSync({ browserSync({
server: { server: {
@ -76,42 +106,15 @@ gulp.task('lint', function () {
.pipe(eslint()) .pipe(eslint())
// eslint.format() outputs the lint results to the console. // eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs). // Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format()) .pipe(eslint.format());
// To have the process exit with an error code (1) on // To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failOnError last. // lint error, return the stream and pipe to failOnError last.
.pipe(eslint.failOnError());
}); });
gulp.task('lint:watch', function () { gulp.task('lint:watch', function () {
gulp.watch('js/**/*.js', ['lint']); 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) { function bundle(watch) {
var bro; var bro;
if (watch) { if (watch) {

View File

@ -1,9 +1,9 @@
jest.autoMockOff(); jest.dontMock('../general_utils');
import * as GeneralUtils from '../general_utils'; import * as GeneralUtils from '../general_utils';
describe('GeneralUtils', () => { describe('GeneralUtils', () => {
it('should do something', () => { it('should do something', () => {
console.log('asdasdasd'); return false;
}); });
}); });

View File

@ -23,11 +23,11 @@
"gulp-concat": "^2.5.2", "gulp-concat": "^2.5.2",
"gulp-eslint": "^0.13.2", "gulp-eslint": "^0.13.2",
"gulp-if": "^1.2.5", "gulp-if": "^1.2.5",
"gulp-jest": "^0.4.0",
"gulp-notify": "^2.2.0", "gulp-notify": "^2.2.0",
"gulp-sass": "^2.0.1", "gulp-sass": "^2.0.1",
"gulp-sourcemaps": "^1.5.2", "gulp-sourcemaps": "^1.5.2",
"gulp-util": "^3.0.4", "gulp-util": "^3.0.4",
"harmonize": "^1.4.2",
"jest-cli": "^0.4.0", "jest-cli": "^0.4.0",
"lodash": "^3.9.3", "lodash": "^3.9.3",
"reactify": "^1.1.0", "reactify": "^1.1.0",
@ -47,13 +47,5 @@
"react-router": "^0.13.3", "react-router": "^0.13.3",
"shmui": "^0.1.0", "shmui": "^0.1.0",
"uglifyjs": "^2.4.10" "uglifyjs": "^2.4.10"
},
"jest": {
"scriptPreprocessor": "node_modules/babel-jest",
"unmockedModulePathPatterns": [
"<rootDir>/node_modules/react",
"<rootDir>/node_modules/alt",
"<rootDir>/js/alt.js"
]
} }
} }