feat(karma-remap-coverage): type definition for v0.1 (#42304)

- type definition
- tests

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz)
2020-02-12 10:53:39 -08:00
committed by GitHub
parent 0cf707a02a
commit f0cbce3dd9
4 changed files with 83 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
// Type definitions for karma-remap-coverage 0.1
// Project: https://github.com/sshev/karma-remap-coverage#readme
// Definitions by: Piotr Błażejewicz (Peter Blazejewicz) <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.2
/// <reference types="karma-coverage" />
import 'karma';
declare module 'karma' {
interface ConfigOptions {
/**
* Key-value pairs where key is report type and value - path to file/dir where to save it.
* Reporters like `text-summary`, `text-lcov` and `teamcity` can print out to console as well
* - in this case just provide any falsy value instead of path.
*
* @example
* ```ts
* 'text-summary': null, // to show summary in console
* html: './coverage/html',
* ```
*
* {@link https://github.com/sshev/karma-remap-coverage#remapcoveragereporter-format }
*/
remapCoverageReporter?: KarmaRemapCoverageReporter;
}
// remapped reporter types to key-value pairs
type KarmaRemapCoverageReporter = Partial<Record<ReporterType, string | null | undefined>>;
}
@@ -0,0 +1,28 @@
import { Config } from 'karma';
module.exports = (config: Config) =>
config.set({
files: ['./entry-module.spec.ts'],
preprocessors: {
'./entry-module.spec.ts': ['webpack', 'sourcemap'],
'./entry-module.ts': ['coverage'],
},
// add both "karma-coverage" and "karma-remap-coverage" reporters
reporters: ['progress', 'coverage', 'remap-coverage'],
// save interim raw coverage report in memory
coverageReporter: {
type: 'in-memory',
},
// define where to save final remaped coverage reports
remapCoverageReporter: {
'text-summary': null,
lcov: undefined,
html: './coverage/html',
cobertura: './coverage/cobertura.xml',
},
// make sure both reporter plugins are loaded
plugins: ['karma-coverage', 'karma-remap-coverage'],
});
+23
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-remap-coverage-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }