diff --git a/karma/karma-tests.ts b/karma/karma-tests.ts new file mode 100644 index 0000000000..b70e7273be --- /dev/null +++ b/karma/karma-tests.ts @@ -0,0 +1,26 @@ +/// +/// + +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); +}); diff --git a/karma/karma.d.ts b/karma/karma.d.ts new file mode 100644 index 0000000000..c66e6fe06a --- /dev/null +++ b/karma/karma.d.ts @@ -0,0 +1,24 @@ +// Type definitions for karma v0.12.37 +// Project: https://github.com/karma-runner/karma +// Definitions by: Tanguy Krotoff +// 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; +}