testing infrastructure

stable
Juanfran 2015-04-15 13:21:53 +02:00
parent 0f0827a690
commit 9c5f0d7a3c
4 changed files with 152 additions and 38 deletions

View File

@ -22,6 +22,8 @@ var gulp = require("gulp"),
autoprefixer = require("gulp-autoprefixer"), autoprefixer = require("gulp-autoprefixer"),
templateCache = require("gulp-angular-templatecache"), templateCache = require("gulp-angular-templatecache"),
runSequence = require("run-sequence"), runSequence = require("run-sequence"),
order = require("gulp-order"),
print = require('gulp-print'),
del = require("del"); del = require("del");
var mainSass = require("./main-sass").files; var mainSass = require("./main-sass").files;
@ -54,30 +56,35 @@ paths.sass = [
"!" + paths.app + "/styles/extras/**/*.scss" "!" + paths.app + "/styles/extras/**/*.scss"
]; ];
paths.coffee = paths.app + "**/*.coffee"; paths.coffee = [
paths.app + "coffee/**/*.coffee",
paths.app + "plugins/**/*.coffee",
"!" + paths.app + "**/*.spec.coffee",
];
paths.js = [ paths.coffee_order = [
paths.tmp + "coffee/app.js", paths.app + "coffee/app.coffee",
paths.tmp + "coffee/*.js", paths.app + "coffee/*.coffee",
paths.tmp + "coffee/modules/controllerMixins.js", paths.app + "coffee/modules/controllerMixins.coffee",
paths.tmp + "coffee/modules/*.js", paths.app + "coffee/modules/*.coffee",
paths.tmp + "coffee/modules/common/*.js", paths.app + "coffee/modules/common/*.coffee",
paths.tmp + "coffee/modules/backlog/*.js", paths.app + "coffee/modules/backlog/*.coffee",
paths.tmp + "coffee/modules/taskboard/*.js", paths.app + "coffee/modules/taskboard/*.coffee",
paths.tmp + "coffee/modules/kanban/*.js", paths.app + "coffee/modules/kanban/*.coffee",
paths.tmp + "coffee/modules/issues/*.js", paths.app + "coffee/modules/issues/*.coffee",
paths.tmp + "coffee/modules/userstories/*.js", paths.app + "coffee/modules/userstories/*.coffee",
paths.tmp + "coffee/modules/tasks/*.js", paths.app + "coffee/modules/tasks/*.coffee",
paths.tmp + "coffee/modules/team/*.js", paths.app + "coffee/modules/team/*.coffee",
paths.tmp + "coffee/modules/wiki/*.js", paths.app + "coffee/modules/wiki/*.coffee",
paths.tmp + "coffee/modules/admin/*.js", paths.app + "coffee/modules/admin/*.coffee",
paths.tmp + "coffee/modules/projects/*.js", paths.app + "coffee/modules/projects/*.coffee",
paths.tmp + "coffee/modules/locales/*.js", paths.app + "coffee/modules/locales/*.coffee",
paths.tmp + "coffee/modules/base/*.js", paths.app + "coffee/modules/base/*.coffee",
paths.tmp + "coffee/modules/resources/*.js", paths.app + "coffee/modules/resources/*.coffee",
paths.tmp + "coffee/modules/user-settings/*.js", paths.app + "coffee/modules/user-settings/*.coffee",
paths.tmp + "coffee/modules/integrations/*.js", paths.app + "coffee/modules/integrations/*.coffee",
paths.tmp + "plugins/**/*.js" paths.app + "plugins/*.coffee",
paths.app + "plugins/**/*.coffee"
]; ];
paths.libs = [ paths.libs = [
@ -267,17 +274,16 @@ gulp.task("locales", function() {
gulp.task("coffee", function() { gulp.task("coffee", function() {
return gulp.src(paths.coffee) return gulp.src(paths.coffee)
.pipe(order(paths.coffee_order, {base: '.'}))
.pipe(sourcemaps.init())
.pipe(cache(coffee())) .pipe(cache(coffee()))
.on("error", function(err) { .on("error", function(err) {
console.log(err.toString()); console.log(err.toString());
this.emit("end"); this.emit("end");
}) })
.pipe(gulp.dest(paths.tmp)); .pipe(concat("app.js"))
}); .pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest(paths.dist + "js/"));
gulp.task("plugins-js", function() {
return gulp.src(paths.app + "plugins/**/*.js")
.pipe(gulp.dest(paths.tmp));
}); });
gulp.task("jslibs-watch", function() { gulp.task("jslibs-watch", function() {
@ -293,22 +299,19 @@ gulp.task("jslibs-deploy", function() {
.pipe(sourcemaps.init()) .pipe(sourcemaps.init())
.pipe(concat("libs.js")) .pipe(concat("libs.js"))
.pipe(uglify({mangle:false, preserveComments: false})) .pipe(uglify({mangle:false, preserveComments: false}))
.pipe(sourcemaps.write("./")) .pipe(sourcemaps.write("./maps"))
.pipe(gulp.dest(paths.dist + "js/")); .pipe(gulp.dest(paths.dist + "js/"));
}); });
gulp.task("app-watch", ["coffee", "plugins-js", "conf", "locales", "app-loader"], function() { gulp.task("app-watch", ["coffee", "conf", "locales", "app-loader"]);
return gulp.src(paths.js)
.pipe(concat("app.js"))
.pipe(gulp.dest(paths.dist + "js/"));
});
gulp.task("app-deploy", ["coffee", "plugins-js", "conf", "locales", "app-loader"], function() { gulp.task("app-deploy", ["coffee", "conf", "locales", "app-loader"], function() {
return gulp.src(paths.js) return gulp.src(paths.dist)
.pipe(order(paths.coffee_order, {base: '.'}))
.pipe(sourcemaps.init()) .pipe(sourcemaps.init())
.pipe(concat("app.js")) .pipe(concat("app.js"))
.pipe(uglify({mangle:false, preserveComments: false})) .pipe(uglify({mangle:false, preserveComments: false}))
.pipe(sourcemaps.write("./")) .pipe(sourcemaps.write("./maps"))
.pipe(gulp.dest(paths.dist + "js/")); .pipe(gulp.dest(paths.dist + "js/"));
}); });
@ -370,6 +373,7 @@ gulp.task("express", function() {
app.use("/fonts", express.static(__dirname + "/dist/fonts")); app.use("/fonts", express.static(__dirname + "/dist/fonts"));
app.use("/plugins", express.static(__dirname + "/dist/plugins")); app.use("/plugins", express.static(__dirname + "/dist/plugins"));
app.use("/locales", express.static(__dirname + "/dist/locales")); app.use("/locales", express.static(__dirname + "/dist/locales"));
app.use("/maps", express.static(__dirname + "/dist/maps"));
app.all("/*", function(req, res, next) { app.all("/*", function(req, res, next) {
//Just send the index.html for other files to support HTML5Mode //Just send the index.html for other files to support HTML5Mode

12
karma.app.conf.js Normal file
View File

@ -0,0 +1,12 @@
window.taigaConfig = {
"api": "http://localhost:8000/api/v1/",
"eventsUrl": null,
"debug": true,
"defaultLanguage": "en",
"publicRegisterEnabled": true,
"feedbackEnabled": true,
"privacyPolicyUrl": null,
"termsOfServiceUrl": null,
"maxUploadFileSize": null,
"contribPlugins": []
}

84
karma.conf.js Normal file
View File

@ -0,0 +1,84 @@
// Karma configuration
// Generated on Wed Apr 15 2015 09:44:14 GMT+0200 (CEST)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'sinon-chai'],
// list of files / patterns to load in the browser
files: [
'karma.app.conf.js',
'dist/js/libs.js',
'node_modules/angular-mocks/angular-mocks.js',
'dist/js/app.js',
'dist/js/templates.js',
'app/coffee/**/*spec.coffee'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'**/*.coffee': ['coffee'],
'dist/js/app.js': ['sourcemap']
},
coffeePreprocessor: {
// options passed to the coffee compiler
options: {
bare: true,
sourceMap: true
},
// transforming the filenames
transformPath: function(path) {
return path.replace(/\.coffee$/, '.js');
}
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};

View File

@ -20,7 +20,9 @@
"scss-lint": "gulp scss-lint --fail" "scss-lint": "gulp scss-lint --fail"
}, },
"devDependencies": { "devDependencies": {
"angular-mocks": "^1.3.15",
"bluebird": "^2.9.21", "bluebird": "^2.9.21",
"chai": "^2.2.0",
"cli-color": "^0.3.3", "cli-color": "^0.3.3",
"coffee-script": "^1.9.1", "coffee-script": "^1.9.1",
"del": "^1.1.1", "del": "^1.1.1",
@ -42,7 +44,9 @@
"gulp-jade": "^1.0.0", "gulp-jade": "^1.0.0",
"gulp-jade-inheritance": "0.5.0", "gulp-jade-inheritance": "0.5.0",
"gulp-minify-css": "^0.4.6", "gulp-minify-css": "^0.4.6",
"gulp-order": "^1.1.1",
"gulp-plumber": "^0.6.6", "gulp-plumber": "^0.6.6",
"gulp-print": "^1.1.0",
"gulp-rename": "^1.2.0", "gulp-rename": "^1.2.0",
"gulp-replace": "^0.5.3", "gulp-replace": "^0.5.3",
"gulp-sass": "^1.3.3", "gulp-sass": "^1.3.3",
@ -52,9 +56,19 @@
"gulp-uglify": "~1.1.0", "gulp-uglify": "~1.1.0",
"gulp-wrap": "^0.11.0", "gulp-wrap": "^0.11.0",
"inquirer": "^0.8.2", "inquirer": "^0.8.2",
"karma": "^0.12.31",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^0.1.7",
"karma-coffee-preprocessor": "^0.2.1",
"karma-mocha": "^0.1.10",
"karma-sinon": "^1.0.4",
"karma-sinon-chai": "^0.3.0",
"karma-sourcemap-loader": "^0.3.4",
"mocha": "^2.2.4",
"pre-commit": "^1.0.5", "pre-commit": "^1.0.5",
"readable-stream": "~1.0.33", "readable-stream": "~1.0.33",
"run-sequence": "^1.0.2", "run-sequence": "^1.0.2",
"sinon": "^1.14.1",
"through2": "~0.6.3" "through2": "~0.6.3"
}, },
"pre-commit": [ "pre-commit": [