gulp.task( 'test', [ 'jslint', 'eslint', 'dropDb' ], function ( pathSource, dontExit ) {

	var sourceFile  = './test/**/*.js';
	var processExit = '';

	if ( pathSource ) {
		sourceFile = pathSource;
	}

	if ( !dontExit ) {
		processExit = exit();
	}

	return gulp.src( sourceFile, {
			'read' : false,
			'base' : '/'
		} )
		.pipe(
			mocha( {
				'reporter' : 'spec'
			} )
		)
		.pipe( coverage.instrument( {
			'pattern'        : [ './src/**/*.js', './config/*.js' ],
			'debugDirectory' : 'debug'
		} ) )
		.pipe( coverage.gather() )
		.pipe( coverage.format( [ {
			'reporter' : 'html',
			'outFile'  : 'coverage.html'
		} ] ) )
		.pipe( gulp.dest( 'reports' ) )
		.pipe( processExit );

} );
Beispiel #2
0
gulp.task('jasmine', function () {
  return gulp.src('lib/**/*.js')
    .pipe(cover.instrument({
      pattern: ['lib/**/*.js', '!lib/**/*Spec.js'],
      debugDirectory: 'debug'
    }))
    .pipe(jasmine())
    .pipe(cover.gather())
    .pipe(cover.format())
    .pipe(gulp.dest('reports'));
});
Beispiel #3
0
gulp.task('unitTest', function(){
    return gulp.src('src/scripts/test/*.js', {read: false})
        .pipe(cover.instrument({
            pattern: ['src/scripts/modules/basketManager.js']
        }))
        // gulp-mocha needs filepaths so you can't have any plugins before it
        .pipe(mocha({reporter: 'spec'}))
        .pipe(cover.gather())
        .pipe(cover.format())
        .pipe(gulp.dest('test'));
});
gulp.task('test', ['jscs', 'lint'], function () {
    return gulp.src('./test', {read: false})
        .pipe(cover.instrument({
            pattern: ['*lib/*.js'],
            debugDirectory: 'debug'
        }))
        .pipe(mocha({reporter: 'nyan'}))
        .pipe(cover.gather())
        .pipe(cover.format())
        .pipe(gulp.dest('reports'));
});
Beispiel #5
0
gulp.task('test-coveralls', ['lint'], function() {
	return gulp.src(['lib/**/*.js', 'test/unit/**/*.js'], { read: false })
		.pipe(cover.instrument({
			pattern: ['lib/**/*.js']
		}))
		.pipe(mocha())
		.pipe(cover.gather())
		.pipe(cover.format({
			reporter: 'lcov'
		}))
		.pipe(coveralls());
});
Beispiel #6
0
gulp.task('coverage', function() {
  return gulp.src(tstRoot + '*.js', {
      read: false
    })
    .pipe(cover.instrument({
      pattern: [srcRoot + '*.js'],
      debugDirectory: 'debug'
    }))
    .pipe(mocha())
    .pipe(cover.gather())
    .pipe(cover.format())
    .pipe(gulp.dest('reports'));
});
Beispiel #7
0
gulp.task('test', ['lint'], function () {
	return gulp.src(['lib/**/*.js', 'test/unit/**/*.js'], { read: false })
		.pipe(jshint())
		.pipe(jshint.reporter('default'))
		.pipe(jshint.reporter('fail'))
		.pipe(cover.instrument({
			pattern: ['lib/**/*.js']
		}))
		.pipe(mocha())
		.pipe(cover.gather())
		.pipe(cover.format())
		.pipe(gulp.dest('reports'));
});
Beispiel #8
0
gulp.task('cover', function () {
    return gulp.src('./test/unit/**/*.test.js', { read: false })
            .pipe(cover.instrument({
                pattern: ['./lib/*.js']
            }))
            .pipe(mocha({
                ui: 'bdd',
                reporter: 'spec',
                timeout: 30000
            }))
            .pipe(cover.gather())
            .pipe(cover.format())
            .pipe(gulp.dest('./.coverdata'));
});
Beispiel #9
0
gulp.task('test', function(){
    gulp.src('test/main.js')
        .pipe(coverage.instrument({
            pattern: ['index.js'],
            debugDirectory: 'debug'
        }))
        .pipe(mocha({
            reporter: 'spec'
        }))
        .pipe(coverage.gather())
        .pipe(coverage.enforce({
            statements: 85,
            lines: 85,
            blocks: 75
        }));
});
gulp.task('test', ['jshint'], function() {
  console.log('Running unit tests');
  return gulp.src(['test/*unit-tests.js'], {read: false})
    .pipe(cover.instrument({
	pattern: ['common/lib/*.js','device/**/*.js','thing/*.js','index.js'],
	debugDirectory: 'debug'
    }))
    .pipe(mocha({
      reporter: 'spec',
      globals: {}
    }))
    .pipe(cover.gather())
    .pipe(cover.format())
    .pipe(gulp.dest('reports'))
    .once('end', function() {
      process.exit();
    });
});
Beispiel #11
0
gulp.task('testc', ['lint'], function(){
    // set up document and window
    global.document = jsdom.jsdom('')
    global.window = document.defaultView

    return gulp.src(['tests/*Test.js'], { read: false })
        .pipe(gulpif(args.cover, cover.instrument({
            pattern: [
                'src/**'
            ]
        })))
        .pipe(mocha({
            reporter: 'spec'
        }))
        .pipe(gulpif(args.cover, cover.gather()))
        .pipe(gulpif(args.cover, processCover))
        .pipe(gulpif(args.cover && args.html, cover.report({
            outFile: 'coverage.html',
            reporter: 'html'
        })))
})
gulp.task('testc', ['lint'], function(){
    // set up window and jquery
    global.window = jsdom.jsdom('').parentWindow
    global.document = window.document
    global.window.$ = require('jquery')

    return gulp.src(['tests/*Test.js'], { read: false })
        .pipe(gulpif(args.cover, cover.instrument({
            pattern: [
                'src/**'
            ]
        })))
        .pipe(mocha({
            reporter: 'spec'
        }))
        .pipe(gulpif(args.cover, cover.gather()))
        .pipe(gulpif(args.cover, processCover))
        .pipe(gulpif(args.cover && args.html, cover.report({
            outFile: 'coverage.html',
            reporter: 'html'
        })))
})
Beispiel #13
0
gulp.task('browserTest', function(){

    // Browser files mocha, chai
    gulp.src('./src/scripts/test/js-frameworks/*.js')
        .pipe(gulp.dest('test'));
    gulp.src('./src/scripts/test/styles/*.css')
        .pipe(gulp.dest('test'));

    // Test spec
    browserify(['./src/scripts/test/basketManager.js'])
        .bundle()
        .pipe(v_src('basketManager.js'))
        .pipe(rename({suffix: "Test"}))
        .pipe(gulp.dest('test'));

    // Tested module
    browserify(['./src/scripts/modules/basketManager.js'])
        .bundle()
        .pipe(v_src('basketManager.js'))
        .pipe(gulp.dest('test'));

    // Test runner
    gulp.src('./src/scripts/test/*.html')
        .pipe(gulp.dest('test'));

    // Run test in console to generate coverage...
    return gulp.src('src/scripts/test/*.js', {read: false})
        .pipe(cover.instrument({
            pattern: ['src/scripts/modules/basketManager.js']
        }))
        // gulp-mocha needs filepaths so you can't have any plugins before it
        .pipe(mocha({reporter: 'spec'}))
        .pipe(cover.gather())
        .pipe(cover.format())
        .pipe(gulp.dest('test'));
});
Beispiel #14
0
gulp.task('test', function () {
    var srcOptions = {
        read: false
    };
    return gulp.src(paths.test, srcOptions)
        .pipe(cover.instrument({
            pattern: paths.js,
            debugDirectory: 'debug'
        }))
        .pipe(mocha({
            reporter: 'nyan'
        }))
        .pipe(cover.gather())
        .pipe(cover.format({
            reporter: 'html',
            outFile: 'coverage.html'
        }))
        .pipe(gulp.dest('reports'))
        .pipe(cover.format({
            reporter: 'json',
            outFile: 'coverage.json'
        }))
        .pipe(gulp.dest('reports'));
});
 gulp.task('gather', function () {
     streamProcessors.push(cover.gather());
 });