feat(karma-json-to-file-reporter): add type definition (#42735)

- type definitions
- tests

https://www.npmjs.com/package/karma-json-to-file-reporter#config

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz)
2020-03-02 10:50:51 -08:00
committed by GitHub
parent 29f196223f
commit cc09dc7d9b
4 changed files with 82 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
// Type definitions for karma-json-to-file-reporter 1.0
// Project: https://github.com/HarryBurns/karma-json-to-file-reporter#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 {
/**
* see {@link https://www.npmjs.com/package/karma-json-to-file-reporter#config}
*/
jsonToFileReporter?: JsonToFileReporterOptions;
}
/**
* JSON messages logged via console.log(_) will be filtered
* and saved to local json file you specified in config.
*/
interface JsonToFileReporterOptions {
/** Path for your json output file. By default it will save your files in the root of your project. */
outputPath?: string;
/**
* File name pattern. You can use wildcards:
* `*timestamp*` - for current karma run timestamp.
* `*index*` - for log entry index: 1, 2, 3, etc.
* @default 'logFile_start-timestamp.json'
*/
fileName?: string;
/**
* Set it true to overwrite files if it already exists. If false, log entries will be added to the end
*/
overwrite?: boolean;
/**
* Filter for json objects. This option can be:
* - string - filter JSONs by field on the root level
* - predicate function
*/
filter?: string | ((obj: object) => boolean);
}
}
@@ -0,0 +1,16 @@
import karma = require('karma');
// Mocha reporter options tests
const mochaReporter: karma.JsonToFileReporterOptions = {
outputPath: 'tests/out/',
};
module.exports = (config: karma.Config) => {
config.set({
jsonToFileReporter: {
outputPath: 'tests/out/',
},
plugins: ['karma-json-to-file-reporter'],
reporters: ['json-to-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-json-to-file-reporter-tests.ts"
]
}
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }