mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
feat(karma-parallel): new definition types (#42984)
- definition files - tests for added configuration options https://github.com/joeljeske/karma-parallel#readme https://github.com/joeljeske/karma-parallel#examples Thanks!
This commit is contained in:
parent
eefb9cb0fd
commit
282a27a0c2
59
types/karma-parallel/index.d.ts
vendored
Normal file
59
types/karma-parallel/index.d.ts
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
// Type definitions for karma-parallel 0.3
|
||||
// Project: https://github.com/joeljeske/karma-parallel#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 ConfigOptions {
|
||||
/**
|
||||
* Options for this plugin
|
||||
* see {@link https://github.com/joeljeske/karma-parallel#options}
|
||||
*/
|
||||
parallelOptions?: ParallelOptions;
|
||||
}
|
||||
interface ParallelOptions {
|
||||
/**
|
||||
* regex or function used to determine if a reporter needs to only received aggregated events from the browser shards.
|
||||
* It is used to ensure coverage reporting is accurate amongst all the shards of a browser
|
||||
* It is also useful for some programmatic reporters such as junit reporters that need to operate on a single set of test outputs and not once for each shard.
|
||||
* Set to null to disable aggregated reporting
|
||||
*/
|
||||
aggregatedReporterTest?: ((reporter: object) => boolean) | RegExp | null;
|
||||
/**
|
||||
* The number of browser instances to use to test.
|
||||
* If you test on multiple types of browsers, this spin up the number of executors for each browser type
|
||||
* @default cpu_cores-1
|
||||
*/
|
||||
executors?: number;
|
||||
/**
|
||||
* This plugin works by overriding the test suite describe() function.
|
||||
* When it encounters a describe, it must decide if it will skip the tests inside of it, or not
|
||||
* @default 'round-robin'
|
||||
*/
|
||||
shardStrategy?: 'round-robin' | 'description-length' | 'custom';
|
||||
/**
|
||||
* Custom function that will determine if a describe block should run in the current executor.
|
||||
* It is a function that is serialized and re-constructed on each executor.
|
||||
* The function will be called for every top level describe block and should return true if the describe block should run for a the current executor
|
||||
*/
|
||||
customShardStrategy?: (options: ShardStrategOptions) => boolean;
|
||||
}
|
||||
|
||||
interface ShardStrategOptions {
|
||||
/**
|
||||
* the total number of executors
|
||||
*/
|
||||
readonly executors: number;
|
||||
/**
|
||||
* the 0-based index of the current executor
|
||||
*/
|
||||
readonly shardIndex: number;
|
||||
/**
|
||||
* the string passed to the describe block (useful for gaining context of the current description)
|
||||
*/
|
||||
readonly description: string;
|
||||
}
|
||||
}
|
||||
33
types/karma-parallel/karma-parallel-tests.ts
Normal file
33
types/karma-parallel/karma-parallel-tests.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import karma = require('karma');
|
||||
|
||||
const configTest = (config: karma.Config) => {
|
||||
config.set({
|
||||
// NOTE: 'parallel' must be the first framework in the list
|
||||
frameworks: ['parallel', 'mocha' /* or 'jasmine' */],
|
||||
files: ['test/**/*.js'],
|
||||
plugins: [
|
||||
// add karma-parallel to the plugins if you encounter something like "karma parallel No provider for framework:parallel"
|
||||
require('karma-parallel'),
|
||||
],
|
||||
parallelOptions: {
|
||||
executors: 4, // Defaults to cpu-count - 1
|
||||
shardStrategy: 'round-robin',
|
||||
customShardStrategy: config => {
|
||||
config.executors; // $ExpectType number
|
||||
config.shardIndex; // $ExpectType number
|
||||
config.description; // $ExpectType string
|
||||
window.parallelDescribeCount = window.parallelDescribeCount || 0;
|
||||
window.parallelDescribeCount++;
|
||||
return window.parallelDescribeCount % config.executors === config.shardIndex;
|
||||
},
|
||||
aggregatedReporterTest: /coverage|istanbul|junit/i,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
// required by window prop definition
|
||||
declare global {
|
||||
interface Window {
|
||||
parallelDescribeCount?: number;
|
||||
}
|
||||
}
|
||||
24
types/karma-parallel/tsconfig.json
Normal file
24
types/karma-parallel/tsconfig.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"DOM"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"karma-parallel-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/karma-parallel/tslint.json
Normal file
1
types/karma-parallel/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user