Skip to content

Commit 1b41238

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

13 files changed

+23
-80
lines changed

gulpfile.js

+7-36
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

+12-4
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

-36
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.

webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
module.exports = {
22
entry: './src/powerbi.ts',
33
output: {
44
path: __dirname + "/dist",

webpack.e2e.config.js renamed to webpack.test.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module.exports = {
2-
entry: './e2e/protocol.e2e.spec.ts',
2+
entry: './test/test.spec.ts',
33
output: {
44
path: __dirname + "/tmp",
5-
filename: 'protocol.e2e.spec.js'
5+
filename: 'test.spec.js'
66
},
77
devtool: 'source-map',
88
resolve: {
@@ -17,6 +17,6 @@ module.exports = {
1717
]
1818
},
1919
ts: {
20-
configFileName: "webpack.e2e.tsconfig.json"
20+
configFileName: "webpack.test.tsconfig.json"
2121
}
2222
}
File renamed without changes.

0 commit comments

Comments
 (0)