Skip to content

Commit 2219f56

Browse files
committed
fix(tests): fixed Karma configuration after latest API changes (v0.13.0)
1 parent 588ebc1 commit 2219f56

2 files changed

Lines changed: 46 additions & 26 deletions

File tree

gulpfile.js

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var gulp = require('gulp'),
1212

1313

1414

15+
1516
// Handle gulp parameters
1617
// ======================
1718

@@ -72,6 +73,7 @@ gulp.task('styles:sass', ['styles:sass:imports'], function () {
7273

7374

7475

76+
7577
// Wire Bower dependencies to source code
7678
// ======================================
7779

@@ -89,6 +91,7 @@ gulp.task('wiredep', function () {
8991

9092

9193

94+
9295
// Prepare JavaScript
9396
// ==================
9497

@@ -133,6 +136,7 @@ gulp.task('scripts:lint', function () {
133136

134137

135138

139+
136140
// Prepare assets
137141
// ==============
138142

@@ -159,6 +163,7 @@ gulp.task('assets', ['assets:img'], function () {
159163

160164

161165

166+
162167
// Prepare HTML
163168
// ============
164169

@@ -197,6 +202,7 @@ gulp.task('html', ['optimize'], function () {
197202

198203

199204

205+
200206
// Perform final optimization
201207
// ==========================
202208

@@ -230,40 +236,25 @@ gulp.task('optimize', ['html:inject'], function () {
230236

231237

232238

239+
233240
// Karma
234241
// =====
235242

236-
var testFiles = [
237-
'vendor/**/*.js',
238-
'!vendor/*jquery*/src/**/*.js',
239-
config.build + '/+(app|common)/**/*.module.js',
240-
config.build + '/+(app|common)/**/*.js',
241-
config.mocks,
242-
config.paths.tests
243-
];
244-
245-
gulp.task('test:run', ['scripts:lint', 'scripts:cacheTpls', 'styles:sass', 'html:inject'] , function () {
246-
// Be sure to return the stream
247-
return gulp.src(testFiles)
248-
.pipe(plugins.karma({
249-
configFile: 'karma.conf.js',
250-
action: 'run'
251-
}))
252-
.on('error', function (err) {
253-
process.exit(1);
254-
});
255-
});
243+
var Server = require('karma').Server;
256244

257-
gulp.task('test:watch', ['scripts:lint', 'scripts:cacheTpls', 'styles:sass', 'html:inject'], function () {
258-
gulp.src(testFiles)
259-
.pipe(plugins.karma({
260-
configFile: 'karma.conf.js',
261-
action: 'watch'
262-
}));
245+
gulp.task('test:run', ['scripts:lint', 'scripts:cacheTpls', 'styles:sass', 'html:inject'] , function (done) {
246+
var cfg = {
247+
configFile: __dirname + '/karma.conf.js',
248+
singleRun: true
249+
};
250+
251+
var server = new Server(cfg, done);
252+
server.start();
263253
});
264254

265255

266256

257+
267258
// Set up Watch
268259
// ============
269260

@@ -280,7 +271,17 @@ gulp.task('watch', ['styles:sass', 'scripts:lint', 'scripts:cacheTpls', 'assets:
280271
'/vendor': './vendor'
281272
},
282273
}
274+
}, function (done) {
275+
if (args.notest) {
276+
return;
277+
}
278+
279+
var cfg = {
280+
configFile: __dirname + '/karma.conf.js'
281+
};
283282

283+
var server = new Server(cfg, done);
284+
server.start();
284285
});
285286

286287
// watch for JS changes
@@ -324,6 +325,7 @@ gulp.task('watch', ['styles:sass', 'scripts:lint', 'scripts:cacheTpls', 'assets:
324325

325326

326327

328+
327329
// Clean up development & production directories
328330
// =============================================
329331

@@ -336,6 +338,7 @@ gulp.task('clean:dist', function (cb) {
336338

337339

338340

341+
339342
// Main gulp tasks
340343
// ===============
341344

karma.conf.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
/* jshint strict: false */
22

3+
var cfg = require('./config.json');
4+
35
module.exports = function (config) {
46
config.set({
7+
exclude: [
8+
'vendor/*jquery*/src/**/*.js'
9+
],
10+
files: [
11+
{ pattern: 'vendor/jquery/dist/jquery.js', watched: false },
12+
{ pattern: 'vendor/angular/angular.js', watched: false },
13+
{ pattern: 'vendor/**/*.js', watched: false },
14+
cfg.build + '/+(app|common)/**/*.module.js',
15+
cfg.build + '/+(app|common)/**/*.config.js',
16+
cfg.build + '/+(app|common)/**/*.controller.js',
17+
cfg.build + '/app/templates.js',
18+
cfg.build + '/app/conf.js',
19+
cfg.paths.tests
20+
],
21+
522
frameworks: ['jasmine'],
623
plugins: ['karma-jasmine', 'karma-phantomjs-launcher', 'karma-coverage'],
724

0 commit comments

Comments
 (0)