From c72d2cfdd0c4a90300dd0da33d98aae09f4b6a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Thu, 6 Feb 2020 19:13:49 +0100 Subject: [PATCH] feat(karma-jasmine): update to version 3.1 (#41989) - version bump - rewrite definition to extend karma configuration with Jasmine specifc configuration properties support - tests updated - type definition configuration changes to match latest recommended setup for linting and TS details Thanks! --- types/karma-jasmine/index.d.ts | 35 ++++++++-- types/karma-jasmine/karma-jasmine-tests.ts | 29 +++++++- types/karma-jasmine/tsconfig.json | 4 +- types/karma-jasmine/tslint.json | 81 +--------------------- 4 files changed, 58 insertions(+), 91 deletions(-) diff --git a/types/karma-jasmine/index.d.ts b/types/karma-jasmine/index.d.ts index 73ca7a480e..bf51b8a2f1 100644 --- a/types/karma-jasmine/index.d.ts +++ b/types/karma-jasmine/index.d.ts @@ -1,10 +1,33 @@ -// Type definitions for karma-jasmine plugin -// Project: https://github.com/karma-runner/karma-jasmine +// Type definitions for karma-jasmine 3.1 +// Project: https://github.com/karma-runner/karma-jasmine#readme // Definitions by: Michel Salib +// Piotr Błażejewicz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 - +// TypeScript Version: 3.2 /// -declare function fdescribe(description: string, specDefinitions: () => void): void; -declare function fit(expectation: string, assertion: () => void): void; +import karma = require('karma'); + +declare module 'karma' { + interface ClientOptions { + jasmine?: jasmine.EnvConfiguration & { + /** @deprecated undocumented to be removed */ + timeoutInterval?: number; + }; + /** + * run a subset of the full set of specs. + * Complete sharding support needs to be done in the process that calls karma, + * and would need to support test result integration across shards. + * See {@link https://github.com/karma-runner/karma-jasmine#sharding} + * + */ + shardIndex?: number; + /** + * run a subset of the full set of specs. + * Complete sharding support needs to be done in the process that calls karma, + * and would need to support test result integration across shards. + * See {@link https://github.com/karma-runner/karma-jasmine#sharding} + */ + totalShards?: number; + } +} diff --git a/types/karma-jasmine/karma-jasmine-tests.ts b/types/karma-jasmine/karma-jasmine-tests.ts index d31c9e415d..39f01543fc 100644 --- a/types/karma-jasmine/karma-jasmine-tests.ts +++ b/types/karma-jasmine/karma-jasmine-tests.ts @@ -1,7 +1,30 @@ +import karma = require('karma'); - -fdescribe("A suite", () => { - fit("contains spec with an expectation", () => { +fdescribe('A suite', () => { + fit('contains spec with an expectation', () => { expect(true).toBe(true); }); }); + +// https://github.com/karma-runner/karma-jasmine#configuration + +const testOne = (config: karma.Config) => { + config.set({ + frameworks: ['jasmine'], + files: ['*.js'], + }); +}; + +const testTwo = (config: karma.Config) => { + config.set({ + client: { + jasmine: { + random: true, + seed: 4321, + oneFailurePerSpec: true, + failFast: true, + timeoutInterval: 1000, + }, + }, + }); +}; diff --git a/types/karma-jasmine/tsconfig.json b/types/karma-jasmine/tsconfig.json index 54f70b6c45..54918eec8e 100644 --- a/types/karma-jasmine/tsconfig.json +++ b/types/karma-jasmine/tsconfig.json @@ -6,8 +6,8 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, "strictFunctionTypes": true, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -20,4 +20,4 @@ "index.d.ts", "karma-jasmine-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/karma-jasmine/tslint.json b/types/karma-jasmine/tslint.json index 3d59f55fda..3db14f85ea 100644 --- a/types/karma-jasmine/tslint.json +++ b/types/karma-jasmine/tslint.json @@ -1,80 +1 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "npm-naming": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} +{ "extends": "dtslint/dt.json" }