From 8379f5d24fc39678737cfa335371b46a2724b542 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:30:57 +0200 Subject: [PATCH] feat(open-wc/testing-karma): new type definition (#43169) - definition file - tests https://github.com/open-wc/open-wc/tree/master/packages/testing-karma#extending-the-config Thanks! --- types/open-wc__testing-karma/index.d.ts | 16 ++++++++ .../open-wc__testing-karma-tests.ts | 37 +++++++++++++++++++ types/open-wc__testing-karma/tsconfig.json | 28 ++++++++++++++ types/open-wc__testing-karma/tslint.json | 1 + 4 files changed, 82 insertions(+) create mode 100644 types/open-wc__testing-karma/index.d.ts create mode 100644 types/open-wc__testing-karma/open-wc__testing-karma-tests.ts create mode 100644 types/open-wc__testing-karma/tsconfig.json create mode 100644 types/open-wc__testing-karma/tslint.json diff --git a/types/open-wc__testing-karma/index.d.ts b/types/open-wc__testing-karma/index.d.ts new file mode 100644 index 0000000000..3a9ea410e9 --- /dev/null +++ b/types/open-wc__testing-karma/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for @open-wc/testing-karma 3.3 +// Project: https://github.com/open-wc/open-wc/tree/master/packages/testing-karma +// Definitions by: Piotr Błażejewicz +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.2 + +import karma = require('karma'); + +/** + * Our configuration sets up karma to run tests based on es modules with the necessary polyfills + * and fallbacks for older browsers and convenient test reporting. + * To extend the karma config, we recommend using `deepmerge`. + * This will do smart merging of complex objects. + * You can extend any of the configuration. + */ +export function createDefaultConfig(config: karma.Config): karma.Config; diff --git a/types/open-wc__testing-karma/open-wc__testing-karma-tests.ts b/types/open-wc__testing-karma/open-wc__testing-karma-tests.ts new file mode 100644 index 0000000000..2176cee75e --- /dev/null +++ b/types/open-wc__testing-karma/open-wc__testing-karma-tests.ts @@ -0,0 +1,37 @@ +import { createDefaultConfig } from '@open-wc/testing-karma'; +import merge = require('lodash/merge'); +import karma = require('karma'); + +module.exports = (config: karma.Config) => { + // defaults + const defaultConfig = createDefaultConfig(config); + // sets config merging defaults with custom settings + config.set( + merge(defaultConfig, { + logLevel: config.LOG_DEBUG, + basePath: '..', + urlRoot: '/base/', + frameworks: ['jasmine'], + files: [ + { pattern: 'lib/angular.js', watched: false }, + 'test/unit/*.spec.js', + { pattern: 'compiled/index.html', watched: false }, + { pattern: 'app/index.html', included: false, served: false }, + { pattern: 'compiled/app.js.map', included: false, served: true, watched: false, nocache: true }, + { pattern: 'test/images/*.jpg', watched: false, included: false, served: true, nocache: false }, + ], + loggers: { + custom: { type: 'file', filename: 'log.txt' }, + }, + reporters: ['progress', 'coverage'], + middleware: ['foo', 'bar'], + beforeMiddleware: ['foo', 'bar'], + mime: { + 'text/x-typescript': ['ts', 'tsx'], + }, + preprocessors: { + 'app.js': ['coverage'], + }, + }), + ); +}; diff --git a/types/open-wc__testing-karma/tsconfig.json b/types/open-wc__testing-karma/tsconfig.json new file mode 100644 index 0000000000..c60d001bfd --- /dev/null +++ b/types/open-wc__testing-karma/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@open-wc/testing-karma": [ + "open-wc__testing-karma" + ] + } + }, + "files": [ + "index.d.ts", + "open-wc__testing-karma-tests.ts" + ] +} diff --git a/types/open-wc__testing-karma/tslint.json b/types/open-wc__testing-karma/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/open-wc__testing-karma/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }