From 418fbfd443bdf14bc7a33077ed3609aa646c2e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Fri, 27 Mar 2020 18:08:22 +0100 Subject: [PATCH] feat(karma-jsdom-launcher): new type definition package (#43031) - type definition - tests https://github.com/badeball/karma-jsdom-launcher#readme Thanks! --- types/karma-jsdom-launcher/index.d.ts | 25 +++++++++++++++++++ .../karma-jsdom-launcher-tests.ts | 24 ++++++++++++++++++ types/karma-jsdom-launcher/tsconfig.json | 24 ++++++++++++++++++ types/karma-jsdom-launcher/tslint.json | 1 + 4 files changed, 74 insertions(+) create mode 100644 types/karma-jsdom-launcher/index.d.ts create mode 100644 types/karma-jsdom-launcher/karma-jsdom-launcher-tests.ts create mode 100644 types/karma-jsdom-launcher/tsconfig.json create mode 100644 types/karma-jsdom-launcher/tslint.json diff --git a/types/karma-jsdom-launcher/index.d.ts b/types/karma-jsdom-launcher/index.d.ts new file mode 100644 index 0000000000..e160c91fc1 --- /dev/null +++ b/types/karma-jsdom-launcher/index.d.ts @@ -0,0 +1,25 @@ +// Type definitions for karma-jsdom-launcher 8.0 +// Project: https://github.com/badeball/karma-jsdom-launcher#readme +// Definitions by: Piotr Błażejewicz (Peter Blazejewicz) +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.2 + +import 'karma'; +import jsdom = require('jsdom'); + +declare module 'karma' { + interface ConfigOptions { + /** + * Launcher for jsdom configuration + */ + jsdomLauncher?: JsdomLauncherOptions; + } + + interface JsdomLauncherOptions { + /** + * You can pass options directly to jsdom as shown below. + * See jsdom's own documentation for all supported options. + */ + jsdom: jsdom.ConstructorOptions; + } +} diff --git a/types/karma-jsdom-launcher/karma-jsdom-launcher-tests.ts b/types/karma-jsdom-launcher/karma-jsdom-launcher-tests.ts new file mode 100644 index 0000000000..ff889ce776 --- /dev/null +++ b/types/karma-jsdom-launcher/karma-jsdom-launcher-tests.ts @@ -0,0 +1,24 @@ +import karma = require('karma'); +import jsdom = require('jsdom'); + +const resourceLoader = new jsdom.ResourceLoader({ + proxy: 'http://127.0.0.1:9001', + strictSSL: false, + userAgent: 'Mellblomenator/9000', +}); +const virtualConsole = new jsdom.VirtualConsole(); +const cookieJar = new jsdom.CookieJar(); + +module.exports = (config: karma.Config) => { + config.set({ + browsers: ['jsdom'], + + jsdomLauncher: { + jsdom: { + resources: resourceLoader, + virtualConsole, + cookieJar, + }, + }, + }); +}; diff --git a/types/karma-jsdom-launcher/tsconfig.json b/types/karma-jsdom-launcher/tsconfig.json new file mode 100644 index 0000000000..1cce2e9d8a --- /dev/null +++ b/types/karma-jsdom-launcher/tsconfig.json @@ -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-jsdom-launcher-tests.ts" + ] +} diff --git a/types/karma-jsdom-launcher/tslint.json b/types/karma-jsdom-launcher/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/karma-jsdom-launcher/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }