Add specialized signature for karma server's on run_complete (#8854)

This commit is contained in:
Nico Jansen
2016-05-01 21:55:29 +09:00
committed by Masahiro Wakame
parent 0c33358b1e
commit b13fb549b2
2 changed files with 28 additions and 5 deletions
+8
View File
@@ -43,6 +43,14 @@ server.on('browser_register', function (browser: any) {
console.log('A new browser was registered');
});
server.on('run_complete', (browsers, results) => {
results.disconnected = false;
results.error = false;
results.exitCode = 0;
results.failed = 9;
results.success = 10;
});
//var runner = require('karma').runner; => cannot use this syntax otherwise runner is of type any
karma.runner.run({port: 9876}, function(exitCode: number) {
console.log('Karma has exited with ' + exitCode);
+20 -5
View File
@@ -34,7 +34,7 @@ declare module 'karma' {
interface LauncherStatic {
generateId(): string;
//TODO: injector should be of type `di.Injector`
new(emitter: NodeJS.EventEmitter, injector: any): Launcher;
new (emitter: NodeJS.EventEmitter, injector: any): Launcher;
}
interface Launcher {
@@ -53,11 +53,19 @@ declare module 'karma' {
}
interface Runner {
run(options?: ConfigOptions|ConfigFile, callback?: ServerCallback): void;
run(options?: ConfigOptions | ConfigFile, callback?: ServerCallback): void;
}
interface TestResults {
disconnected: boolean;
error: boolean;
exitCode: number;
failed: number;
success: number;
}
interface Server extends NodeJS.EventEmitter {
new(options?: ConfigOptions|ConfigFile, callback?: ServerCallback): Server;
new (options?: ConfigOptions | ConfigFile, callback?: ServerCallback): Server;
/**
* Start the server
*/
@@ -72,6 +80,13 @@ declare module 'karma' {
*/
refreshFiles(): Promise<any>;
on(event: string, listener: Function): this;
/**
* Listen to the 'run_complete' event.
*/
on(event: 'run_complete', listener: (browsers: any, results: TestResults ) => void): this;
///**
// * Backward-compatibility with karma-intellij bundled with WebStorm.
// * Deprecated since version 0.13, to be removed in 0.14
@@ -191,7 +206,7 @@ declare module 'karma' {
* @default []
* @description List of files/patterns to load in the browser.
*/
files?: (FilePattern|string)[];
files?: (FilePattern | string)[];
/**
* @default []
* @description List of test frameworks you want to use. Typically, you will set this to ['jasmine'], ['mocha'] or ['qunit']...
@@ -257,7 +272,7 @@ declare module 'karma' {
* but your interactive debugging does not.
*
*/
preprocessors?: { [name: string]: string|string[] }
preprocessors?: { [name: string]: string | string[] }
/**
* @default 'http:'
* Possible Values: