Skip to content

Commit

Permalink
chore(build): fix karma not exiting properly (angular#1741)
Browse files Browse the repository at this point in the history
* Fixes the Karma tasks not exiting properly. This is an issue, because doing a keyboard interrupt doesn't stop the Gulp watchers that are going on in the background.
* Increase the time that Karma waits before starting to run tests. This should help mitigate the multiple reloads when running unit tests locally.

Related to angular#1681.
  • Loading branch information
crisbeto authored and jelbourn committed Nov 11, 2016
1 parent adfc4d1 commit 77701cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions test/karma.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function config(config) {
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
autoWatchBatchDelay: 500,

sauceLabs: {
testName: 'material2',
Expand Down
10 changes: 5 additions & 5 deletions tools/gulp/tasks/unit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import gulp = require('gulp');
import path = require('path');
import gulpMerge = require('merge2');

import {PROJECT_ROOT, DIST_COMPONENTS_ROOT} from '../constants';
import {PROJECT_ROOT} from '../constants';
import {sequenceTask} from '../task_helpers';

const karma = require('karma');
Expand Down Expand Up @@ -48,20 +48,20 @@ gulp.task(':test:deps:inline', sequenceTask(':test:deps', ':inline-resources'));
*
* This task should be used when running unit tests locally.
*/
gulp.task('test', [':test:watch'], (done: () => void) => {
gulp.task('test', [':test:watch'], () => {
new karma.Server({
configFile: path.join(PROJECT_ROOT, 'test/karma.conf.js')
}, done).start();
}).start();
});

/**
* Runs the unit tests once with inlined resources (html, css). Does not watch for changes.
*
* This task should be used when running tests on the CI server.
*/
gulp.task('test:single-run', [':test:deps:inline'], (done: () => void) => {
gulp.task('test:single-run', [':test:deps:inline'], () => {
new karma.Server({
configFile: path.join(PROJECT_ROOT, 'test/karma.conf.js'),
singleRun: true
}, done).start();
}).start();
});

0 comments on commit 77701cc

Please sign in to comment.