{"size": 2550, "ext": "js", "max_stars_repo_path": "Frontend/utmocha/gulpfile.js", "max_stars_repo_name": "mind0n/hive", "max_stars_repo_stars_event_min_datetime": "2017-03-03T02:13:16.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-18T09:59:56.000Z", "max_issues_repo_path": "Frontend/utmocha/gulpfile.js", "max_issues_repo_name": "mind0n/hive", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Frontend/utmocha/gulpfile.js", "max_forks_repo_name": "mind0n/hive", "max_forks_repo_forks_event_min_datetime": "2016-11-15T05:20:12.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-13T16:32:11.000Z"}
{"max_stars_count": 5, "max_issues_count": null, "max_forks_count": 4, "avg_line_length": 27.1276595745, "max_line_length": 104, "alphanum_fraction": 0.6203921569}
'use strict';

var gulp        = require('gulp');
var gutil       = require('gulp-util');
var mocha       = require('gulp-mocha');
var istanbul    = require('gulp-istanbul');
var isparta     = require('isparta');
var runSequence = require('run-sequence');
var factor      = require("factor-bundle");

var browserify  = require("browserify");
var source      = require('vinyl-source-stream');
var tsify       = require("tsify");
var web         = require("gulp-webserver");

// Transform all required files with Babel
require('babel-register');

// Files to process
var TEST_FILES = 'dist/tests/**/*test*.js';
var SRC_FILES = 'dist/tests/**/*test*.js';

gulp.task("ut", function () {
    return browserify({
        basedir: '.',
        debug: true,
        entries: ['spec/tests.ts', 'spec/tests2.ts'],
        cache: {},
        packageCache: {}
    })
    .external(["chai"])
    .plugin(tsify)
    //.plugin(factor, {o:['dist/tests/tests.js', 'dist/tests/tests2.js']})
    .bundle()
    //.pipe(source('common.js'))
    .pipe(source('tests.js'))
    .pipe(gulp.dest("dist/tests"));
});

gulp.task("utwatch", ["ut"], function(){
    gulp.watch("./spec/**/*.*", ["ut"]);
});

/*
 * Instrument files using istanbul and isparta
 */
gulp.task('coverage:instrument', function() {
  return gulp.src(SRC_FILES)
    .pipe(istanbul({
      instrumenter: isparta.Instrumenter // Use the isparta instrumenter (code coverage for ES6)
      // Istanbul configuration (see https://github.com/SBoudrias/gulp-istanbul#istanbulopt)
      // ...
    }))
    .pipe(istanbul.hookRequire()); // Force `require` to return covered files
});

/*
 * Write coverage reports after test success
 */
gulp.task('coverage:report', function(done) {
  return gulp.src(SRC_FILES, {read: false})
    .pipe(istanbul.writeReports({
      // Istanbul configuration (see https://github.com/SBoudrias/gulp-istanbul#istanbulwritereportsopt)
      // ...
    }));
});

/**
 * Run unit tests
 */
gulp.task('test', function() {
  return gulp.src(TEST_FILES, {read: false})
    .pipe(mocha({
      //require: [__dirname + '/lib/jsdom'] // Prepare environement for React/JSX testing
      //require:[__dirname + "\\dist\\tests\\common.js"]
    }));
});

/**
 * Run unit tests with code coverage
 */
gulp.task('test:coverage', function(done) {
  runSequence('coverage:instrument', 'test', 'coverage:report', done);
});

/**
 * Watch files and run unit tests on changes
 */
gulp.task('tdd', function(done) {
  gulp.watch([
    TEST_FILES,
    SRC_FILES
  ], ['test']).on('error', gutil.log);
});