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!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-04-01 00:30:57 +02:00 committed by GitHub
parent 94403d6d8f
commit 8379f5d24f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 82 additions and 0 deletions

16
types/open-wc__testing-karma/index.d.ts vendored Normal file
View File

@ -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 <https://github.com/peterblazejewicz>
// 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;

View File

@ -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'],
},
}),
);
};

View File

@ -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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }