feat(karma-mocha): types for v1.3 (#42371)

- type definition
- tests

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-02-14 18:35:42 +01:00 committed by GitHub
parent 2112ad14c8
commit fca28df8dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 87 additions and 0 deletions

22
types/karma-mocha/index.d.ts vendored Normal file
View File

@ -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) <https://github.com/peterblazejewicz>
// 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;
}
}

View File

@ -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',
};

View File

@ -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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }