From fca28df8ddba0dd3d6a201c8eff67b299f9d3b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Fri, 14 Feb 2020 18:35:42 +0100 Subject: [PATCH] feat(karma-mocha): types for v1.3 (#42371) - type definition - tests Thanks! --- types/karma-mocha/index.d.ts | 22 ++++++++++++++ types/karma-mocha/karma-mocha-tests.ts | 41 ++++++++++++++++++++++++++ types/karma-mocha/tsconfig.json | 23 +++++++++++++++ types/karma-mocha/tslint.json | 1 + 4 files changed, 87 insertions(+) create mode 100644 types/karma-mocha/index.d.ts create mode 100644 types/karma-mocha/karma-mocha-tests.ts create mode 100644 types/karma-mocha/tsconfig.json create mode 100644 types/karma-mocha/tslint.json 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" }