Skip to content

Commit

Permalink
Consolidate all tests so they can be run with single command: gulp te…
Browse files Browse the repository at this point in the history
…st --chrome
  • Loading branch information
mattmazzola committed Jun 16, 2016
1 parent 3f8aef4 commit 1b41238
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 80 deletions.
43 changes: 7 additions & 36 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var rename = require('gulp-rename'),
paths = require('./paths'),
webpack = require('webpack-stream'),
webpackConfig = require('./webpack.config'),
webpackConfigE2E = require('./webpack.e2e.config'),
webpackTestConfig = require('./webpack.test.config'),
runSequence = require('run-sequence'),
argv = require('yargs').argv;
;
Expand All @@ -33,21 +33,12 @@ gulp.task('lint', 'Lints all files', function (done) {

gulp.task('test', 'Runs all tests', function (done) {
runSequence(
['compile:ts', 'compile:spec'],
['min:js'],
'compile:spec',
'test:js',
done
);
});

gulp.task('teste2e', 'Runs e2e tests', function (done) {
runSequence(
'compile:e2e',
'test:e2e',
done
);
});

gulp.task('build', 'Runs a full build', function (done) {
runSequence(
'lint',
Expand Down Expand Up @@ -77,14 +68,6 @@ gulp.task('min:js', 'Creates minified JavaScript file', function() {
.pipe(gulp.dest(paths.jsDest));
});

gulp.task('test:js', 'Runs unit tests', function(done) {
new karma.Server.start({
configFile: __dirname + '/karma.conf.js',
singleRun: argv.debug ? false : true,
captureTimeout: argv.timeout || 60000
}, done);
});

gulp.task('compile:ts', 'Compile typescript for powerbi library', function() {
return gulp.src(['./src/powerbi.ts'])
.pipe(webpack(webpackConfig))
Expand All @@ -104,27 +87,15 @@ gulp.task('compile:dts', 'Generate single dts file from modules', function (done
.pipe(gulp.dest('dist/'));
});

gulp.task('compile:spec', 'Compile typescript for tests', function () {
var tsProject = ts.createProject('tsconfig.json');

var tsResult = gulp.src(['./typings/global/**/*.d.ts', './test/core.spec.ts', './test/embed.spec.ts'])
.pipe(ts(tsProject))
;

return tsResult.js
.pipe(flatten())
gulp.task('compile:spec', 'Compile spec tests', function () {
return gulp.src(['./test/test.spec.ts'])
.pipe(webpack(webpackTestConfig))
.pipe(gulp.dest('./tmp'));
});

gulp.task('compile:e2e', 'Compile End-to-End tests', function () {
return gulp.src(['./e2e/protocol.e2e.spec.ts'])
.pipe(webpack(webpackConfigE2E))
.pipe(gulp.dest('./tmpe2e'));
});

gulp.task('test:e2e', 'Run End-to-End tests', function (done) {
gulp.task('test:js', 'Run js tests', function (done) {
new karma.Server.start({
configFile: __dirname + '/karma.e2e.conf.js',
configFile: __dirname + '/karma.conf.js',
singleRun: argv.debug ? false : true,
captureTimeout: argv.timeout || 60000
}, done);
Expand Down
16 changes: 12 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,33 @@ var argv = require('yargs').argv;
module.exports = function (config) {
config.set({
frameworks: ['jasmine'],
files: paths.karmaFiles,
files: [
'./node_modules/jquery/dist/jquery.js',
'./node_modules/es6-promise/dist/es6-promise.js',
'./tmp/**/*.js',
{ pattern: './test/**/*.html', served: true, included: false }
],
exclude: [],
reporters: argv.debug ? ['spec'] : ['spec', 'coverage'],
autoWatch: true,
browsers: [argv.debug ? 'Chrome' : 'PhantomJS'],
browsers: [argv.chrome ? 'Chrome' : 'PhantomJS'],
plugins: [
'karma-chrome-launcher',
'karma-jasmine',
'karma-spec-reporter',
'karma-phantomjs-launcher',
'karma-coverage'
],
preprocessors: { './src/**/*.js': ['coverage'] },
preprocessors: { './tmp/**/*.js': ['coverage'] },
coverageReporter: {
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
logLevel: argv.debug ? config.LOG_DEBUG : config.LOG_INFO
logLevel: argv.debug ? config.LOG_DEBUG : config.LOG_INFO,
client: {
args: argv.logMessages ? ['logMessages']: []
}
});
};
36 changes: 0 additions & 36 deletions karma.e2e.conf.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
module.exports = {
entry: './src/powerbi.ts',
output: {
path: __dirname + "/dist",
Expand Down
6 changes: 3 additions & 3 deletions webpack.e2e.config.js → webpack.test.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
entry: './e2e/protocol.e2e.spec.ts',
entry: './test/test.spec.ts',
output: {
path: __dirname + "/tmp",
filename: 'protocol.e2e.spec.js'
filename: 'test.spec.js'
},
devtool: 'source-map',
resolve: {
Expand All @@ -17,6 +17,6 @@ module.exports = {
]
},
ts: {
configFileName: "webpack.e2e.tsconfig.json"
configFileName: "webpack.test.tsconfig.json"
}
}
File renamed without changes.

0 comments on commit 1b41238

Please sign in to comment.