diff --git a/types/karma-mocha/index.d.ts b/types/karma-mocha/index.d.ts new file mode 100644 index 0000000000..50a6f3b497 --- /dev/null +++ b/types/karma-mocha/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for karma-mocha 1.3 +// Project: https://github.com/karma-runner/karma-mocha#readme +// Definitions by: Piotr Błażejewicz (Peter Blazejewicz) +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.2 + +import 'karma'; + +declare module 'karma' { + interface ClientOptions { + mocha?: MochaClientOptions; + } + + interface MochaClientOptions { + /** This will be exposed in a reporter as `result.mocha.{exportedValue}` */ + export?: string[]; + /** You can set opts to equal true then plugin will load opts from default location 'test/mocha.opts' */ + opts?: true | string; + /** any supported Mocha configuration options */ + [key: string]: any; + } +} diff --git a/types/karma-mocha/karma-mocha-tests.ts b/types/karma-mocha/karma-mocha-tests.ts new file mode 100644 index 0000000000..6312711d30 --- /dev/null +++ b/types/karma-mocha/karma-mocha-tests.ts @@ -0,0 +1,41 @@ +import karma = require('karma'); + +module.exports = (config: karma.Config) => { + config.set({ + frameworks: ['mocha', 'chai'], + files: ['src/**/*.js', 'test/**/*.js'], + reporters: ['progress'], + port: 9876, // karma web server port + colors: true, + logLevel: config.LOG_INFO, + browsers: ['Chrome'], + autoWatch: false, + concurrency: Infinity, + client: { + mocha: { + // karma-mocha options + expose: ['body '], + // opts: './test/mocha.opts', + opts: true, + // mocha options + ui: 'bdd', + }, + }, + }); +}; + +const mochaClientOptionsTestOne: karma.MochaClientOptions = { + expose: [], + opts: true, + ui: 'bdd', +}; + +const mochaClientOptionsTestTwo: karma.MochaClientOptions = { + expose: ['body'], + opts: 'test/mocha.opts', + ui: 'bdd', +}; + +const mochaClientOptionsTestThree: karma.MochaClientOptions = { + ui: 'bdd', +}; diff --git a/types/karma-mocha/tsconfig.json b/types/karma-mocha/tsconfig.json new file mode 100644 index 0000000000..5e2ed3f99f --- /dev/null +++ b/types/karma-mocha/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "karma-mocha-tests.ts" + ] +} diff --git a/types/karma-mocha/tslint.json b/types/karma-mocha/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/karma-mocha/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }