Phillip Kerman
@phillip
phillipkerman.com/wv2014
Terms, perspective, tips for learning
Learn Git Branching
Install packages (usually from the web)
-g
global flag--save
flag adds dependencyGet dependencies for a project via its package.json or bower.json file
Learning
Basic GruntFile.js
module.exports = function(grunt){
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
//set up uglify
uglify: {
build: {
src: 'main.js',
dest: '_dist/main.min.js'
}
},
more: { demo: "na"}
});
//into package.json via: npm install grunt-contrib-uglify --save-dev
grunt.loadNpmTasks('grunt-contrib-uglify');
//register what to do when using the default 'grunt' command
grunt.registerTask('default', ['uglify', 'more']);
}
Basic gulpfile.js
//npm install gulp --save-dev
var gulp = require('gulp');
//npm install gulp-uglify --save-dev
var uglify = require('gulp-uglify');
gulp.task('default', function() {
gulp.src('./main.js')
.pipe(uglify())
.pipe(gulp.dest('./_dist/main.min.js'));
});
//keeps running
gulp.watch('./main.js',['default']);
Process
Basic syntax
//spec: describe('myAddFunction', function(){ it('should know one and one is two', function(){ expect(myAddFunction(1,1)).toEqual(2); }); });
//code to test function myAddFunction(a,b){ return null; }
More
describe('myAddFunction', function(){
beforeEach(function() {
//set some globals
});
it('should know one and one is two', function(){
expect(myAddFunction(1,1)).toEqual(2);
});
});
Also, mocks for integration testing and CI
Just use Yeoman
Phillip Kerman | @phillip
phillipkerman.com/wv2014