From 9a4e62fa4d2eae68c59a9700ee683dc94dc39818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Wed, 1 Apr 2020 00:21:50 +0200 Subject: [PATCH] feat(karma-html-detailed-reporter): new type definition files (#43032) * feat(karma-html-detailed-reporter): new type definition files - definition file - tests https://github.com/a11smiles/karma-html-detailed-reporter#options Thanks! * Add module exports fixing PR comments Thanks! --- types/karma-html-detailed-reporter/index.d.ts | 71 +++++++++++++++++++ .../karma-html-detailed-reporter-tests.ts | 27 +++++++ .../tsconfig.json | 23 ++++++ .../karma-html-detailed-reporter/tslint.json | 1 + 4 files changed, 122 insertions(+) create mode 100644 types/karma-html-detailed-reporter/index.d.ts create mode 100644 types/karma-html-detailed-reporter/karma-html-detailed-reporter-tests.ts create mode 100644 types/karma-html-detailed-reporter/tsconfig.json create mode 100644 types/karma-html-detailed-reporter/tslint.json diff --git a/types/karma-html-detailed-reporter/index.d.ts b/types/karma-html-detailed-reporter/index.d.ts new file mode 100644 index 0000000000..ee3964832a --- /dev/null +++ b/types/karma-html-detailed-reporter/index.d.ts @@ -0,0 +1,71 @@ +// Type definitions for karma-html-detailed-reporter 2.1 +// Project: https://github.com/a11smiles/karma-html-detailed-reporter +// Definitions by: Piotr Błażejewicz (Peter Blazejewicz) +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.2 + +import 'karma'; + +declare module 'karma' { + interface ConfigOptions { + /** + * The reporter provides a dashboard detailing specification runs + * see {@link https://github.com/a11smiles/karma-html-detailed-reporter#options} + */ + htmlDetailed?: HtmlDetailedOptions; + } + + /** + * see {@link https://github.com/a11smiles/karma-html-detailed-reporter#options} + */ + interface HtmlDetailedOptions { + /** + * Enables/disables the refresh to start automatically + * @default true + */ + autoReload?: boolean; + /** + * Sets the reports output base path + * @default './_reports' + */ + dir?: string; + /** + * Sets the refresh timeout (in milliseconds) for the page + * @default 1000 + */ + refreshTimeout?: number; + /** + * Determines whether the results are split into a separate file for each browser + * @default true + */ + splitResults?: boolean; + /** + * Determines whether the detailed results of the successfull tests are default shown or hidden in the browser (you are able to toggle live in the browser) + * @default true + */ + showSuccess?: boolean; + /** + * Determines whether the detailed results of the failed tests are default shown or hidden in the browser (you are able to toggle live in the browser) + * @default true + */ + showFailed?: boolean; + /** + * Determines whether the detailed results of the skipped tests are default shown or hidden in the browser (you are able to toggle live in the browser) + * @default true + */ + showSkipped?: boolean; + /** + * Determines whether to use the hosted versions of Boostrap and jQuery. If testing within a CI build (e.g. TFS, Jenkins, TeamCity), + * setting this to true would allow you to see the reports while the builders do not maintain node modules. + * @default false + */ + useHostedBootstrap?: boolean; + } +} + +declare const exp: { + 'preprocessor:htmlDetailed': ['factory', any]; + 'reporter:htmlDetailed': ['type', any]; +}; + +export = exp; diff --git a/types/karma-html-detailed-reporter/karma-html-detailed-reporter-tests.ts b/types/karma-html-detailed-reporter/karma-html-detailed-reporter-tests.ts new file mode 100644 index 0000000000..b5eef999c4 --- /dev/null +++ b/types/karma-html-detailed-reporter/karma-html-detailed-reporter-tests.ts @@ -0,0 +1,27 @@ +import karma = require('karma'); +import karmaHtmlDetailedReporter = require('karma-html-detailed-reporter'); + +// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/README.md#basic +module.exports = (config: karma.Config) => { + config.set({ + frameworks: ['jasmine'], + reporters: ['progress', 'htmlDetailed'], + browsers: ['Chrome', 'PhantomJS'], + plugins: ['karma-jasmine', 'karma-chrome-launcher', 'karma-html-detailed-reporter'], + + // (test) configure the reporter + htmlDetailed: { + autoReload: true, + dir: './_reports', + refreshTimeout: 1000, + splitResults: true, + showSuccess: true, + showFailed: false, + showSkipped: true, + useHostedBootstrap: true, + }, + }); +}; + +const [factory, preprocessor] = karmaHtmlDetailedReporter['preprocessor:htmlDetailed']; +const [type, reporter] = karmaHtmlDetailedReporter['reporter:htmlDetailed']; diff --git a/types/karma-html-detailed-reporter/tsconfig.json b/types/karma-html-detailed-reporter/tsconfig.json new file mode 100644 index 0000000000..d7431ff2bf --- /dev/null +++ b/types/karma-html-detailed-reporter/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-html-detailed-reporter-tests.ts" + ] +} diff --git a/types/karma-html-detailed-reporter/tslint.json b/types/karma-html-detailed-reporter/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/karma-html-detailed-reporter/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }