[jasmine] Add definition for jasmine.Env.configure and mark methods as deprecated (#40013)

* Add definition for jasmine.Env.configure and mark Env methods throwOnExpectationFailure, stopOnSpecFailure, seed and randomizeTests as deprecated

* Rename Configuration to EnvConfiguration to prevent possible naaming conflicts

* Synchronize files in ts3.1 and root

* Move EnvConfiguration to jasmine namespace
This commit is contained in:
Dominik Ehrenberg
2019-11-05 22:41:46 +01:00
committed by Nathan Shively-Sanders
parent 7664182296
commit 64de1d9aec
4 changed files with 68 additions and 6 deletions

View File

@@ -14,6 +14,7 @@
// Stephen Farrar <https://github.com/stephenfarrar>
// Mochamad Arfin <https://github.com/ndunks>
// Alex Povar <https://github.com/zvirja>
// Dominik Ehrenberg <https://github.com/djungowski>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// For ddescribe / iit use : https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts
@@ -203,6 +204,18 @@ declare namespace jasmine {
(ReadonlyArray<string> | { [methodName: string]: any }) :
(ReadonlyArray<keyof T> | { [P in keyof T]?: T[P] extends Func ? ReturnType<T[P]> : any });
/**
* Configuration that can be used when configuring Jasmine via {@link jasmine.Env.configure}
*/
interface EnvConfiguration {
random?: boolean;
seed?: number;
failFast?: boolean;
oneFailurePerSpec?: boolean;
hideDisabled?: boolean;
specFilter?: Function;
}
function clock(): Clock;
var matchersUtil: MatchersUtil;
@@ -371,14 +384,28 @@ declare namespace jasmine {
addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
addMatchers(matchers: CustomMatcherFactories): void;
specFilter(spec: Spec): boolean;
/**
* @deprecated Use oneFailurePerSpec option in {@link jasmine.Env.configure} instead.
*/
throwOnExpectationFailure(value: boolean): void;
/**
* @deprecated Use failFast option in {@link jasmine.Env.configure} instead.
*/
stopOnSpecFailure(value: boolean): void;
/**
* @deprecated Use seed option in {@link jasmine.Env.configure} instead.
*/
seed(seed: string | number): string | number;
provideFallbackReporter(reporter: Reporter): void;
throwingExpectationFailures(): boolean;
allowRespy(allow: boolean): void;
randomTests(): boolean;
/**
* @deprecated Use random option in {@link jasmine.Env.configure} instead.
*/
randomizeTests(b: boolean): void;
clearReporters(): void;
configure(configuration: EnvConfiguration): void;
}
interface FakeTimer {

View File

@@ -1413,15 +1413,19 @@ describe("Randomize Tests", () => {
it("should allow randomization of the order of tests", () => {
expect(() => {
const env = jasmine.getEnv();
env.randomizeTests(true);
env.configure({
random: true
});
}).not.toThrow();
});
it("should allow a seed to be passed in for randomization", () => {
expect(() => {
const env = jasmine.getEnv();
env.randomizeTests(true);
return env.seed(1234);
env.configure({
random: true,
seed: 1234
});
}).not.toThrow();
});
});

View File

@@ -13,6 +13,7 @@
// Stephen Farrar <https://github.com/stephenfarrar>
// Mochamad Arfin <https://github.com/ndunks>
// Alex Povar <https://github.com/zvirja>
// Dominik Ehrenberg <https://github.com/djungowski>
// For ddescribe / iit use : https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts
/**
@@ -206,6 +207,18 @@ declare namespace jasmine {
(ReadonlyArray<string> | { [methodName: string]: any }) :
(ReadonlyArray<keyof T> | { [P in keyof T]?: T[P] extends Func ? ReturnType<T[P]> : any });
/**
* Configuration that can be used when configuring Jasmine via {@link jasmine.Env.configure}
*/
interface EnvConfiguration {
random?: boolean;
seed?: number;
failFast?: boolean;
oneFailurePerSpec?: boolean;
hideDisabled?: boolean;
specFilter?: Function;
}
function clock(): Clock;
var matchersUtil: MatchersUtil;
@@ -374,14 +387,28 @@ declare namespace jasmine {
addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
addMatchers(matchers: CustomMatcherFactories): void;
specFilter(spec: Spec): boolean;
/**
* @deprecated Use oneFailurePerSpec option in {@link jasmine.Env.configure} instead.
*/
throwOnExpectationFailure(value: boolean): void;
/**
* @deprecated Use failFast option in {@link jasmine.Env.configure} instead.
*/
stopOnSpecFailure(value: boolean): void;
/**
* @deprecated Use seed option in {@link jasmine.Env.configure} instead.
*/
seed(seed: string | number): string | number;
provideFallbackReporter(reporter: Reporter): void;
throwingExpectationFailures(): boolean;
allowRespy(allow: boolean): void;
randomTests(): boolean;
/**
* @deprecated Use random option in {@link jasmine.Env.configure} instead.
*/
randomizeTests(b: boolean): void;
clearReporters(): void;
configure(configuration: EnvConfiguration): void;
}
interface FakeTimer {

View File

@@ -1413,15 +1413,19 @@ describe("Randomize Tests", () => {
it("should allow randomization of the order of tests", () => {
expect(() => {
const env = jasmine.getEnv();
env.randomizeTests(true);
env.configure({
random: true
});
}).not.toThrow();
});
it("should allow a seed to be passed in for randomization", () => {
expect(() => {
const env = jasmine.getEnv();
env.randomizeTests(true);
return env.seed(1234);
env.configure({
random: true,
seed: 1234
});
}).not.toThrow();
});
});