Add definitions for Karma public API (https://github.com/karma-runner/karma)

This commit is contained in:
Tanguy Krotoff
2015-07-06 15:10:22 +02:00
parent b73d1fd0bf
commit dbcd2f192c
2 changed files with 50 additions and 0 deletions

26
karma/karma-tests.ts Normal file
View File

@@ -0,0 +1,26 @@
/// <reference path="karma.d.ts" />
/// <reference path="../gulp/gulp.d.ts" />
import gulp = require('gulp');
import karma = require('karma');
function runKarma(singleRun: boolean): void {
karma.server.start({
configFile: __dirname + '/karma.conf.js',
singleRun: singleRun
});
}
gulp.task('test:unit:karma', ['build:test:unit'], () => runKarma(true));
karma.server.start({port: 9876}, (exitCode) => {
console.log('Karma has exited with ' + exitCode);
process.exit(exitCode);
});
karma.runner.run({port: 9876}, (exitCode) => {
console.log('Karma has exited with ' + exitCode);
process.exit(exitCode);
});

24
karma/karma.d.ts vendored Normal file
View File

@@ -0,0 +1,24 @@
// Type definitions for karma v0.12.37
// Project: https://github.com/karma-runner/karma
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'karma' {
// See Karma public API https://karma-runner.github.io/0.12/dev/public-api.html
interface IKarmaServer {
start(options?: any, callback?: (exitCode: number) => void): void;
}
interface IKarmaRunner {
run(options?: any, callback?: (exitCode: number) => void): void;
}
interface IKarma {
server: IKarmaServer;
runner: IKarmaRunner;
}
var karma: IKarma;
export = karma;
}