Skip to content

Commit 1b41238

Browse files
author
Matt Mazzola
committed
Consolidate all tests so they can be run with single command: gulp test --chrome
1 parent 3f8aef4 commit 1b41238

13 files changed

Lines changed: 23 additions & 80 deletions

gulpfile.js

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var rename = require('gulp-rename'),
1414
paths = require('./paths'),
1515
webpack = require('webpack-stream'),
1616
webpackConfig = require('./webpack.config'),
17-
webpackConfigE2E = require('./webpack.e2e.config'),
17+
webpackTestConfig = require('./webpack.test.config'),
1818
runSequence = require('run-sequence'),
1919
argv = require('yargs').argv;
2020
;
@@ -33,21 +33,12 @@ gulp.task('lint', 'Lints all files', function (done) {
3333

3434
gulp.task('test', 'Runs all tests', function (done) {
3535
runSequence(
36-
['compile:ts', 'compile:spec'],
37-
['min:js'],
36+
'compile:spec',
3837
'test:js',
3938
done
4039
);
4140
});
4241

43-
gulp.task('teste2e', 'Runs e2e tests', function (done) {
44-
runSequence(
45-
'compile:e2e',
46-
'test:e2e',
47-
done
48-
);
49-
});
50-
5142
gulp.task('build', 'Runs a full build', function (done) {
5243
runSequence(
5344
'lint',
@@ -77,14 +68,6 @@ gulp.task('min:js', 'Creates minified JavaScript file', function() {
7768
.pipe(gulp.dest(paths.jsDest));
7869
});
7970

80-
gulp.task('test:js', 'Runs unit tests', function(done) {
81-
new karma.Server.start({
82-
configFile: __dirname + '/karma.conf.js',
83-
singleRun: argv.debug ? false : true,
84-
captureTimeout: argv.timeout || 60000
85-
}, done);
86-
});
87-
8871
gulp.task('compile:ts', 'Compile typescript for powerbi library', function() {
8972
return gulp.src(['./src/powerbi.ts'])
9073
.pipe(webpack(webpackConfig))
@@ -104,27 +87,15 @@ gulp.task('compile:dts', 'Generate single dts file from modules', function (done
10487
.pipe(gulp.dest('dist/'));
10588
});
10689

107-
gulp.task('compile:spec', 'Compile typescript for tests', function () {
108-
var tsProject = ts.createProject('tsconfig.json');
109-
110-
var tsResult = gulp.src(['./typings/global/**/*.d.ts', './test/core.spec.ts', './test/embed.spec.ts'])
111-
.pipe(ts(tsProject))
112-
;
113-
114-
return tsResult.js
115-
.pipe(flatten())
90+
gulp.task('compile:spec', 'Compile spec tests', function () {
91+
return gulp.src(['./test/test.spec.ts'])
92+
.pipe(webpack(webpackTestConfig))
11693
.pipe(gulp.dest('./tmp'));
11794
});
11895

119-
gulp.task('compile:e2e', 'Compile End-to-End tests', function () {
120-
return gulp.src(['./e2e/protocol.e2e.spec.ts'])
121-
.pipe(webpack(webpackConfigE2E))
122-
.pipe(gulp.dest('./tmpe2e'));
123-
});
124-
125-
gulp.task('test:e2e', 'Run End-to-End tests', function (done) {
96+
gulp.task('test:js', 'Run js tests', function (done) {
12697
new karma.Server.start({
127-
configFile: __dirname + '/karma.e2e.conf.js',
98+
configFile: __dirname + '/karma.conf.js',
12899
singleRun: argv.debug ? false : true,
129100
captureTimeout: argv.timeout || 60000
130101
}, done);

karma.conf.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,33 @@ var argv = require('yargs').argv;
44
module.exports = function (config) {
55
config.set({
66
frameworks: ['jasmine'],
7-
files: paths.karmaFiles,
7+
files: [
8+
'./node_modules/jquery/dist/jquery.js',
9+
'./node_modules/es6-promise/dist/es6-promise.js',
10+
'./tmp/**/*.js',
11+
{ pattern: './test/**/*.html', served: true, included: false }
12+
],
813
exclude: [],
914
reporters: argv.debug ? ['spec'] : ['spec', 'coverage'],
1015
autoWatch: true,
11-
browsers: [argv.debug ? 'Chrome' : 'PhantomJS'],
16+
browsers: [argv.chrome ? 'Chrome' : 'PhantomJS'],
1217
plugins: [
1318
'karma-chrome-launcher',
1419
'karma-jasmine',
1520
'karma-spec-reporter',
1621
'karma-phantomjs-launcher',
1722
'karma-coverage'
1823
],
19-
preprocessors: { './src/**/*.js': ['coverage'] },
24+
preprocessors: { './tmp/**/*.js': ['coverage'] },
2025
coverageReporter: {
2126
reporters: [
2227
{ type: 'html' },
2328
{ type: 'text-summary' }
2429
]
2530
},
26-
logLevel: argv.debug ? config.LOG_DEBUG : config.LOG_INFO
31+
logLevel: argv.debug ? config.LOG_DEBUG : config.LOG_INFO,
32+
client: {
33+
args: argv.logMessages ? ['logMessages']: []
34+
}
2735
});
2836
};

karma.e2e.conf.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)