1 | // Type definitions for Jasmine 3.8
|
2 | // Project: http://jasmine.github.io
|
3 | // Definitions by: Boris Yankov <https://github.com/borisyankov>
|
4 | // Theodore Brown <https://github.com/theodorejb>
|
5 | // David Pärsson <https://github.com/davidparsson>
|
6 | // Lukas Zech <https://github.com/lukas-zech-software>
|
7 | // Boris Breuer <https://github.com/Engineer2B>
|
8 | // Chris Yungmann <https://github.com/cyungmann>
|
9 | // Giles Roadnight <https://github.com/Roaders>
|
10 | // Yaroslav Admin <https://github.com/devoto13>
|
11 | // Domas Trijonis <https://github.com/fdim>
|
12 | // Moshe Kolodny <https://github.com/kolodny>
|
13 | // Stephen Farrar <https://github.com/stephenfarrar>
|
14 | // Dominik Ehrenberg <https://github.com/djungowski>
|
15 | // Chives <https://github.com/chivesrs>
|
16 | // kirjs <https://github.com/kirjs>
|
17 | // Md. Enzam Hossain <https://github.com/ienzam>
|
18 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
19 |
|
20 | // For ddescribe / iit use : https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts
|
21 |
|
22 | /**
|
23 | * @deprecated Use {@link jasmine.ImplementationCallback} instead.
|
24 | */
|
25 | type ImplementationCallback = jasmine.ImplementationCallback;
|
26 |
|
27 | /**
|
28 | * Create a group of specs (often called a suite).
|
29 | * @param description Textual description of the group
|
30 | * @param specDefinitions Function for Jasmine to invoke that will define inner suites a specs
|
31 | */
|
32 | declare function describe(description: string, specDefinitions: () => void): void;
|
33 |
|
34 | /**
|
35 | * A focused `describe`. If suites or specs are focused, only those that are focused will be executed.
|
36 | * @param description Textual description of the group
|
37 | * @param specDefinitions Function for Jasmine to invoke that will define inner suites a specs
|
38 | */
|
39 | declare function fdescribe(description: string, specDefinitions: () => void): void;
|
40 |
|
41 | /**
|
42 | * A temporarily disabled `describe`. Specs within an xdescribe will be marked pending and not executed.
|
43 | * @param description Textual description of the group
|
44 | * @param specDefinitions Function for Jasmine to invoke that will define inner suites a specs
|
45 | */
|
46 | declare function xdescribe(description: string, specDefinitions: () => void): void;
|
47 |
|
48 | /**
|
49 | * Define a single spec. A spec should contain one or more expectations that test the state of the code.
|
50 | * A spec whose expectations all succeed will be passing and a spec with any failures will fail.
|
51 | * @param expectation Textual description of what this spec is checking
|
52 | * @param assertion Function that contains the code of your test. If not provided the test will be pending.
|
53 | * @param timeout Custom timeout for an async spec.
|
54 | */
|
55 | declare function it(expectation: string, assertion?: jasmine.ImplementationCallback, timeout?: number): void;
|
56 |
|
57 | /**
|
58 | * A focused `it`. If suites or specs are focused, only those that are focused will be executed.
|
59 | * @param expectation Textual description of what this spec is checking
|
60 | * @param assertion Function that contains the code of your test. If not provided the test will be pending.
|
61 | * @param timeout Custom timeout for an async spec.
|
62 | */
|
63 | declare function fit(expectation: string, assertion?: jasmine.ImplementationCallback, timeout?: number): void;
|
64 |
|
65 | /**
|
66 | * A temporarily disabled `it`. The spec will report as pending and will not be executed.
|
67 | * @param expectation Textual description of what this spec is checking
|
68 | * @param assertion Function that contains the code of your test. If not provided the test will be pending.
|
69 | * @param timeout Custom timeout for an async spec.
|
70 | */
|
71 | declare function xit(expectation: string, assertion?: jasmine.ImplementationCallback, timeout?: number): void;
|
72 |
|
73 | /**
|
74 | * Mark a spec as pending, expectation results will be ignored.
|
75 | * If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending.
|
76 | * @param reason Reason the spec is pending.
|
77 | */
|
78 | declare function pending(reason?: string): void;
|
79 |
|
80 | /**
|
81 | * Sets a user-defined property that will be provided to reporters as
|
82 | * part of the properties field of SpecResult.
|
83 | * @since 3.6.0
|
84 | */
|
85 | declare function setSpecProperty(key: string, value: unknown): void;
|
86 |
|
87 | /**
|
88 | * Sets a user-defined property that will be provided to reporters as
|
89 | * part of the properties field of SuiteResult.
|
90 | * @since 3.6.0
|
91 | */
|
92 | declare function setSuiteProperty(key: string, value: unknown): void;
|
93 |
|
94 | /**
|
95 | * Run some shared setup before each of the specs in the describe in which it is called.
|
96 | * @param action Function that contains the code to setup your specs.
|
97 | * @param timeout Custom timeout for an async beforeEach.
|
98 | */
|
99 | declare function beforeEach(action: jasmine.ImplementationCallback, timeout?: number): void;
|
100 |
|
101 | /**
|
102 | * Run some shared teardown after each of the specs in the describe in which it is called.
|
103 | * @param action Function that contains the code to teardown your specs.
|
104 | * @param timeout Custom timeout for an async afterEach.
|
105 | */
|
106 | declare function afterEach(action: jasmine.ImplementationCallback, timeout?: number): void;
|
107 |
|
108 | /**
|
109 | * Run some shared setup once before all of the specs in the describe are run.
|
110 | * Note: Be careful, sharing the setup from a beforeAll makes it easy to accidentally leak state between your specs so that they erroneously pass or fail.
|
111 | * @param action Function that contains the code to setup your specs.
|
112 | * @param timeout Custom timeout for an async beforeAll.
|
113 | */
|
114 | declare function beforeAll(action: jasmine.ImplementationCallback, timeout?: number): void;
|
115 |
|
116 | /**
|
117 | * Run some shared teardown once before all of the specs in the describe are run.
|
118 | * Note: Be careful, sharing the teardown from a afterAll makes it easy to accidentally leak state between your specs so that they erroneously pass or fail.
|
119 | * @param action Function that contains the code to teardown your specs.
|
120 | * @param timeout Custom timeout for an async afterAll
|
121 | */
|
122 | declare function afterAll(action: jasmine.ImplementationCallback, timeout?: number): void;
|
123 |
|
124 | /**
|
125 | * Create an expectation for a spec.
|
126 | * @checkReturnValue see https://tsetse.info/check-return-value
|
127 | * @param spy
|
128 | */
|
129 | declare function expect<T extends jasmine.Func>(spy: T | jasmine.Spy<T>): jasmine.FunctionMatchers<T>;
|
130 |
|
131 | /**
|
132 | * Create an expectation for a spec.
|
133 | * @checkReturnValue see https://tsetse.info/check-return-value
|
134 | * @param actual
|
135 | */
|
136 | declare function expect<T>(actual: ArrayLike<T>): jasmine.ArrayLikeMatchers<T>;
|
137 |
|
138 | /**
|
139 | * Create an expectation for a spec.
|
140 | * @checkReturnValue see https://tsetse.info/check-return-value
|
141 | * @param actual Actual computed value to test expectations against.
|
142 | */
|
143 | declare function expect<T>(actual: T): jasmine.Matchers<T>;
|
144 |
|
145 | /**
|
146 | * Create an expectation for a spec.
|
147 | */
|
148 | declare function expect(): jasmine.NothingMatcher;
|
149 |
|
150 | /**
|
151 | * Create an asynchronous expectation for a spec. Note that the matchers
|
152 | * that are provided by an asynchronous expectation all return promises
|
153 | * which must be either returned from the spec or waited for using `await`
|
154 | * in order for Jasmine to associate them with the correct spec.
|
155 | * @checkReturnValue see https://tsetse.info/check-return-value
|
156 | * @param actual Actual computed value to test expectations against.
|
157 | */
|
158 | declare function expectAsync<T, U>(actual: T | PromiseLike<T>): jasmine.AsyncMatchers<T, U>;
|
159 |
|
160 | /**
|
161 | * Explicitly mark a spec as failed.
|
162 | * @param e Reason for the failure
|
163 | */
|
164 | declare function fail(e?: any): void;
|
165 |
|
166 | /**
|
167 | * Action method that should be called when the async work is complete.
|
168 | */
|
169 | interface DoneFn extends Function {
|
170 | (): void;
|
171 |
|
172 | /** fails the spec and indicates that it has completed. If the message is an Error, Error.message is used */
|
173 | fail: (message?: Error | string) => void;
|
174 | }
|
175 |
|
176 | /**
|
177 | * Install a spy onto an existing object.
|
178 | * @param object The object upon which to install the `Spy`.
|
179 | * @param method The name of the method to replace with a `Spy`.
|
180 | */
|
181 | declare function spyOn<T, K extends keyof T = keyof T>(
|
182 | object: T,
|
183 | method: T[K] extends Function ? K : never,
|
184 | ): jasmine.Spy<
|
185 | T[K] extends jasmine.Func ? T[K] : T[K] extends { new (...args: infer A): infer V } ? (...args: A) => V : never
|
186 | >;
|
187 |
|
188 | /**
|
189 | * Install a spy on a property installed with `Object.defineProperty` onto an existing object.
|
190 | * @param object The object upon which to install the `Spy`.
|
191 | * @param property The name of the property to replace with a `Spy`.
|
192 | * @param accessType The access type (get|set) of the property to `Spy` on.
|
193 | */
|
194 | declare function spyOnProperty<T>(object: T, property: keyof T, accessType?: "get" | "set"): jasmine.Spy;
|
195 |
|
196 | /**
|
197 | * Installs spies on all writable and configurable properties of an object.
|
198 | * @param object The object upon which to install the `Spy`s.
|
199 | * @param includeNonEnumerable Whether or not to add spies to non-enumerable properties.
|
200 | */
|
201 | declare function spyOnAllFunctions<T>(object: T, includeNonEnumerable?: boolean): jasmine.SpyObj<T>;
|
202 |
|
203 | declare namespace jasmine {
|
204 | type Func = (...args: any[]) => any;
|
205 |
|
206 | // Use trick with prototype to allow abstract classes.
|
207 | // More info: https://stackoverflow.com/a/38642922/2009373
|
208 | type Constructor = Function & { prototype: any };
|
209 |
|
210 | type ImplementationCallback = (() => PromiseLike<any>) | (() => void) | ((done: DoneFn) => void);
|
211 |
|
212 | type ExpectedRecursive<T> =
|
213 | | T
|
214 | | ObjectContaining<T>
|
215 | | AsymmetricMatcher<any>
|
216 | | {
|
217 | [K in keyof T]: ExpectedRecursive<T[K]> | Any;
|
218 | };
|
219 | type Expected<T> =
|
220 | | T
|
221 | | ObjectContaining<T>
|
222 | | AsymmetricMatcher<any>
|
223 | | Any
|
224 | | Spy
|
225 | | {
|
226 | [K in keyof T]: ExpectedRecursive<T[K]>;
|
227 | };
|
228 | type SpyObjMethodNames<T = undefined> = T extends undefined
|
229 | ? ReadonlyArray<string> | { [methodName: string]: any }
|
230 | : ReadonlyArray<keyof T> | { [P in keyof T]?: T[P] extends Func ? ReturnType<T[P]> : any };
|
231 |
|
232 | type SpyObjPropertyNames<T = undefined> = T extends undefined
|
233 | ? ReadonlyArray<string> | { [propertyName: string]: any }
|
234 | : ReadonlyArray<keyof T> | { [P in keyof T]?: T[P] };
|
235 |
|
236 | /**
|
237 | * Configuration that can be used when configuring Jasmine via {@link jasmine.Env.configure}
|
238 | */
|
239 | interface EnvConfiguration {
|
240 | /**
|
241 | * Whether to randomize spec execution order
|
242 | * @since 3.3.0
|
243 | * @default true
|
244 | */
|
245 | random?: boolean | undefined;
|
246 | /**
|
247 | * Seed to use as the basis of randomization.
|
248 | * Null causes the seed to be determined randomly at the start of execution.
|
249 | * @since 3.3.0
|
250 | * @default null
|
251 | */
|
252 | seed?: number | string | undefined;
|
253 | /**
|
254 | * Whether to stop execution of the suite after the first spec failure
|
255 | * @since 3.3.0
|
256 | * @default false
|
257 | */
|
258 | failFast?: boolean | undefined;
|
259 | /**
|
260 | * Whether to fail the spec if it ran no expectations. By default
|
261 | * a spec that ran no expectations is reported as passed. Setting this
|
262 | * to true will report such spec as a failure.
|
263 | * @since 3.5.0
|
264 | * @default false
|
265 | */
|
266 | failSpecWithNoExpectations?: boolean | undefined;
|
267 | /**
|
268 | * Whether to cause specs to only have one expectation failure.
|
269 | * @since 3.3.0
|
270 | * @default false
|
271 | */
|
272 | oneFailurePerSpec?: boolean | undefined;
|
273 | /**
|
274 | * Function to use to filter specs
|
275 | * @since 3.3.0
|
276 | * @default true
|
277 | */
|
278 | specFilter?: Function | undefined;
|
279 | /**
|
280 | * Whether or not reporters should hide disabled specs from their output.
|
281 | * Currently only supported by Jasmine's HTMLReporter
|
282 | * @since 3.3.0
|
283 | * @default false
|
284 | */
|
285 | hideDisabled?: boolean | undefined;
|
286 | /**
|
287 | * Set to provide a custom promise library that Jasmine will use if it needs
|
288 | * to create a promise. If not set, it will default to whatever global Promise
|
289 | * library is available (if any).
|
290 | * @since 3.5.0
|
291 | * @default undefined
|
292 | */
|
293 | Promise?: Function | undefined;
|
294 | }
|
295 |
|
296 | function clock(): Clock;
|
297 | function DiffBuilder(): DiffBuilder;
|
298 |
|
299 | var matchersUtil: MatchersUtil;
|
300 |
|
301 | /**
|
302 | * That will succeed if the actual value being compared is an instance of the specified class/constructor.
|
303 | */
|
304 | function any(aclass: Constructor | Symbol): AsymmetricMatcher<any>;
|
305 |
|
306 | /**
|
307 | * That will succeed if the actual value being compared is not `null` and not `undefined`.
|
308 | */
|
309 | function anything(): AsymmetricMatcher<any>;
|
310 |
|
311 | /**
|
312 | * That will succeed if the actual value being compared is `true` or anything truthy.
|
313 | * @since 3.1.0
|
314 | */
|
315 | function truthy(): AsymmetricMatcher<any>;
|
316 |
|
317 | /**
|
318 | * That will succeed if the actual value being compared is `null`, `undefined`, `0`, `false` or anything falsey.
|
319 | * @since 3.1.0
|
320 | */
|
321 | function falsy(): AsymmetricMatcher<any>;
|
322 |
|
323 | /**
|
324 | * That will succeed if the actual value being compared is empty.
|
325 | * @since 3.1.0
|
326 | */
|
327 | function empty(): AsymmetricMatcher<any>;
|
328 |
|
329 | /**
|
330 | * That will succeed if the actual value being compared is not empty.
|
331 | * @since 3.1.0
|
332 | */
|
333 | function notEmpty(): AsymmetricMatcher<any>;
|
334 |
|
335 | function arrayContaining<T>(sample: ArrayLike<T>): ArrayContaining<T>;
|
336 | function arrayWithExactContents<T>(sample: ArrayLike<T>): ArrayContaining<T>;
|
337 | function objectContaining<T>(sample: { [K in keyof T]?: ExpectedRecursive<T[K]> }): ObjectContaining<T>;
|
338 | function mapContaining<K, V>(sample: Map<K, V>): AsymmetricMatcher<Map<K, V>>;
|
339 | function setContaining<T>(sample: Set<T>): AsymmetricMatcher<Set<T>>;
|
340 |
|
341 | function setDefaultSpyStrategy<Fn extends Func = Func>(fn?: (and: SpyAnd<Fn>) => void): void;
|
342 | function addSpyStrategy<Fn extends Func = Func>(name: string, factory: Fn): void;
|
343 | function createSpy<Fn extends Func>(name?: string, originalFn?: Fn): Spy<Fn>;
|
344 | function createSpyObj(baseName: string, methodNames: SpyObjMethodNames, propertyNames?: SpyObjPropertyNames): any;
|
345 | function createSpyObj<T>(
|
346 | baseName: string,
|
347 | methodNames: SpyObjMethodNames<T>,
|
348 | propertyNames?: SpyObjPropertyNames<T>,
|
349 | ): SpyObj<T>;
|
350 | function createSpyObj(methodNames: SpyObjMethodNames, propertyNames?: SpyObjPropertyNames): any;
|
351 | function createSpyObj<T>(methodNames: SpyObjMethodNames<T>, propertyNames?: SpyObjPropertyNames<T>): SpyObj<T>;
|
352 |
|
353 | function pp(value: any): string;
|
354 |
|
355 | function getEnv(): Env;
|
356 |
|
357 | function addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
|
358 |
|
359 | /**
|
360 | * Add a custom object formatter for the current scope of specs.
|
361 | * Note: This is only callable from within a beforeEach, it, or beforeAll.
|
362 | * @since 3.6.0
|
363 | * @see https://jasmine.github.io/tutorials/custom_object_formatters
|
364 | */
|
365 | function addCustomObjectFormatter(formatter: CustomObjectFormatter): void;
|
366 |
|
367 | function addMatchers(matchers: CustomMatcherFactories): void;
|
368 | function addAsyncMatchers(matchers: CustomAsyncMatcherFactories): void;
|
369 |
|
370 | function stringMatching(str: string | RegExp): AsymmetricMatcher<string>;
|
371 |
|
372 | /**
|
373 | * @deprecated Private method that may be changed or removed in the future
|
374 | */
|
375 | function formatErrorMsg(domain: string, usage: string): (msg: string) => string;
|
376 |
|
377 | interface Any extends AsymmetricMatcher<any> {
|
378 | new (expectedClass: any): any;
|
379 | jasmineToString(): string;
|
380 | }
|
381 |
|
382 | interface AsymmetricMatcher<TValue> {
|
383 | /**
|
384 | * customTesters are deprecated and will be replaced with matcherUtils in the future.
|
385 | */
|
386 | asymmetricMatch(other: TValue, matchersUtil?: MatchersUtil | ReadonlyArray<CustomEqualityTester>): boolean;
|
387 | jasmineToString?(): string;
|
388 | }
|
389 |
|
390 | // taken from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains()
|
391 | interface ArrayLike<T> {
|
392 | length: number;
|
393 | [n: number]: T;
|
394 | }
|
395 |
|
396 | interface ArrayContaining<T> extends AsymmetricMatcher<any> {
|
397 | new?(sample: ArrayLike<T>): ArrayLike<T>;
|
398 | jasmineToString(): string;
|
399 | }
|
400 |
|
401 | interface ObjectContaining<T> extends AsymmetricMatcher<T> {
|
402 | new?(sample: { [K in keyof T]?: any }): { [K in keyof T]?: any };
|
403 |
|
404 | jasmineToString?(): string;
|
405 | }
|
406 |
|
407 | interface Clock {
|
408 | install(): Clock;
|
409 | uninstall(): void;
|
410 | /** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */
|
411 | tick(ms: number): void;
|
412 | mockDate(date?: Date): void;
|
413 | withMock(func: () => void): void;
|
414 | }
|
415 |
|
416 | type CustomEqualityTester = (first: any, second: any) => boolean | void;
|
417 |
|
418 | type CustomObjectFormatter = (value: unknown) => string | undefined;
|
419 |
|
420 | interface CustomMatcher {
|
421 | compare<T>(actual: T, expected: T, ...args: any[]): CustomMatcherResult;
|
422 | compare(actual: any, ...expected: any[]): CustomMatcherResult;
|
423 | negativeCompare?<T>(actual: T, expected: T, ...args: any[]): CustomMatcherResult;
|
424 | negativeCompare?(actual: any, ...expected: any[]): CustomMatcherResult;
|
425 | }
|
426 |
|
427 | interface CustomAsyncMatcher {
|
428 | compare<T>(actual: T, expected: T, ...args: any[]): PromiseLike<CustomMatcherResult>;
|
429 | compare(actual: any, ...expected: any[]): PromiseLike<CustomMatcherResult>;
|
430 | negativeCompare?<T>(actual: T, expected: T, ...args: any[]): PromiseLike<CustomMatcherResult>;
|
431 | negativeCompare?(actual: any, ...expected: any[]): PromiseLike<CustomMatcherResult>;
|
432 | }
|
433 |
|
434 | type CustomMatcherFactory = (
|
435 | util: MatchersUtil,
|
436 | customEqualityTesters: ReadonlyArray<CustomEqualityTester>,
|
437 | ) => CustomMatcher;
|
438 |
|
439 | type CustomAsyncMatcherFactory = (
|
440 | util: MatchersUtil,
|
441 | customEqualityTesters: ReadonlyArray<CustomEqualityTester>,
|
442 | ) => CustomAsyncMatcher;
|
443 |
|
444 | interface CustomMatcherFactories {
|
445 | [name: string]: CustomMatcherFactory;
|
446 | }
|
447 |
|
448 | interface CustomAsyncMatcherFactories {
|
449 | [name: string]: CustomAsyncMatcherFactory;
|
450 | }
|
451 |
|
452 | interface CustomMatcherResult {
|
453 | pass: boolean;
|
454 | message?: string | undefined;
|
455 | }
|
456 |
|
457 | interface DiffBuilder {
|
458 | setRoots(actual: any, expected: any): void;
|
459 | recordMismatch(formatter?: (actual: any, expected: any, path?: any, prettyPrinter?: any) => string): void;
|
460 | withPath(pathComponent: string, block: () => void): void;
|
461 | getMessage(): string;
|
462 | }
|
463 |
|
464 | interface MatchersUtil {
|
465 | equals(a: any, b: any, customTesters?: ReadonlyArray<CustomEqualityTester>, diffBuilder?: DiffBuilder): boolean;
|
466 | contains<T>(
|
467 | haystack: ArrayLike<T> | string,
|
468 | needle: any,
|
469 | customTesters?: ReadonlyArray<CustomEqualityTester>,
|
470 | ): boolean;
|
471 | buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: any[]): string;
|
472 |
|
473 | /**
|
474 | * Formats a value for use in matcher failure messages and similar
|
475 | * contexts, taking into account the current set of custom value
|
476 | * formatters.
|
477 | * @since 3.6.0
|
478 | * @param value The value to pretty-print
|
479 | * @return The pretty-printed value
|
480 | */
|
481 | pp: typeof pp;
|
482 | }
|
483 |
|
484 | interface Env {
|
485 | addReporter(reporter: CustomReporter): void;
|
486 | allowRespy(allow: boolean): void;
|
487 | clearReporters(): void;
|
488 | configuration(): EnvConfiguration;
|
489 | configure(configuration: EnvConfiguration): void;
|
490 | execute(runnablesToRun?: Suite[], onComplete?: Func): void;
|
491 | /**
|
492 | * @deprecated Use hideDisabled option in {@link jasmine.Env.configure} instead.
|
493 | */
|
494 | hideDisabled(value: boolean): void;
|
495 | /**
|
496 | * @deprecated Check hideDisabled option in {@link jasmine.Env.configuration} instead.
|
497 | */
|
498 | hidingDisabled(): boolean;
|
499 | provideFallbackReporter(reporter: CustomReporter): void;
|
500 | /**
|
501 | * @deprecated Check random option in {@link jasmine.Env.configuration} instead.
|
502 | */
|
503 | randomTests(): boolean;
|
504 | /**
|
505 | * @deprecated Use random option in {@link jasmine.Env.configure} instead.
|
506 | */
|
507 | randomizeTests(value: boolean): void;
|
508 | /**
|
509 | * @deprecated Use seed option in {@link jasmine.Env.configure} instead.
|
510 | */
|
511 | seed(value?: number | string): number | string;
|
512 | /**
|
513 | * Sets a user-defined property that will be provided to reporters as
|
514 | * part of the properties field of SpecResult.
|
515 | * @since 3.6.0
|
516 | */
|
517 | setSpecProperty: typeof setSpecProperty;
|
518 | /**
|
519 | * Sets a user-defined property that will be provided to reporters as
|
520 | * part of the properties field of SuiteResult.
|
521 | * @since 3.6.0
|
522 | */
|
523 | setSuiteProperty: typeof setSuiteProperty;
|
524 | /**
|
525 | * @deprecated Use specFilter option in {@link jasmine.Env.configure} instead.
|
526 | */
|
527 | specFilter(spec: Spec): boolean;
|
528 | /**
|
529 | * @deprecated Use failFast option in {@link jasmine.Env.configure} instead.
|
530 | */
|
531 | stopOnSpecFailure(value: boolean): void;
|
532 | /**
|
533 | * @deprecated Check failFast option in {@link jasmine.Env.configuration} instead.
|
534 | */
|
535 | stoppingOnSpecFailure(): boolean;
|
536 | /**
|
537 | * @deprecated Use oneFailurePerSpec option in {@link jasmine.Env.configure} instead.
|
538 | */
|
539 | throwOnExpectationFailure(value: boolean): void;
|
540 | /**
|
541 | * @deprecated Check oneFailurePerSpec option in {@link jasmine.Env.configuration} instead.
|
542 | */
|
543 | throwingExpectationFailures(): boolean;
|
544 | topSuite(): Suite;
|
545 | }
|
546 |
|
547 | interface HtmlReporter {
|
548 | new (): any;
|
549 | }
|
550 |
|
551 | interface HtmlSpecFilter {
|
552 | new (): any;
|
553 | }
|
554 |
|
555 | interface Result {
|
556 | type: string;
|
557 | }
|
558 |
|
559 | interface ExpectationResult extends Result {
|
560 | matcherName: string;
|
561 | message: string;
|
562 | stack: string;
|
563 | passed: boolean;
|
564 | expected: any;
|
565 | actual: any;
|
566 | }
|
567 |
|
568 | interface DeprecationWarning extends Result {
|
569 | message: string;
|
570 | stack: string;
|
571 | }
|
572 |
|
573 | interface Order {
|
574 | new (options: { random: boolean; seed: number | string }): any;
|
575 | random: boolean;
|
576 | seed: number | string;
|
577 | sort<T>(items: T[]): T[];
|
578 | }
|
579 |
|
580 | namespace errors {
|
581 | class ExpectationFailed extends Error {
|
582 | constructor();
|
583 |
|
584 | stack: any;
|
585 | }
|
586 | }
|
587 |
|
588 | interface Matchers<T> {
|
589 | /**
|
590 | * Expect the actual value to be `===` to the expected value.
|
591 | *
|
592 | * @param expected The expected value to compare against.
|
593 | * @example
|
594 | * expect(thing).toBe(realThing);
|
595 | */
|
596 | toBe(expected: Expected<T>): void;
|
597 | /**
|
598 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
599 | */
|
600 | // tslint:disable-next-line unified-signatures
|
601 | toBe(expected: Expected<T>, expectationFailOutput: any): void;
|
602 |
|
603 | /**
|
604 | * Expect the actual value to be equal to the expected, using deep equality comparison.
|
605 | * @param expected Expected value.
|
606 | * @example
|
607 | * expect(bigObject).toEqual({ "foo": ['bar', 'baz'] });
|
608 | */
|
609 | toEqual(expected: Expected<T>): void;
|
610 | /**
|
611 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
612 | */
|
613 | // tslint:disable-next-line unified-signatures
|
614 | toEqual(expected: Expected<T>, expectationFailOutput: any): void;
|
615 |
|
616 | /**
|
617 | * Expect the actual value to match a regular expression.
|
618 | * @param expected Value to look for in the string.
|
619 | * @example
|
620 | * expect("my string").toMatch(/string$/);
|
621 | * expect("other string").toMatch("her");
|
622 | */
|
623 | toMatch(expected: string | RegExp): void;
|
624 | /**
|
625 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
626 | */
|
627 | // tslint:disable-next-line unified-signatures
|
628 | toMatch(expected: string | RegExp, expectationFailOutput: any): void;
|
629 |
|
630 | toBeDefined(): void;
|
631 | /**
|
632 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
633 | */
|
634 | // tslint:disable-next-line unified-signatures
|
635 | toBeDefined(expectationFailOutput: any): void;
|
636 | toBeUndefined(): void;
|
637 | /**
|
638 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
639 | */
|
640 | // tslint:disable-next-line unified-signatures
|
641 | toBeUndefined(expectationFailOutput: any): void;
|
642 | toBeNull(): void;
|
643 | /**
|
644 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
645 | */
|
646 | // tslint:disable-next-line unified-signatures
|
647 | toBeNull(expectationFailOutput: any): void;
|
648 | toBeNaN(): void;
|
649 | toBeTruthy(): void;
|
650 | /**
|
651 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
652 | */
|
653 | // tslint:disable-next-line unified-signatures
|
654 | toBeTruthy(expectationFailOutput: any): void;
|
655 | toBeFalsy(): void;
|
656 | /**
|
657 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
658 | */
|
659 | // tslint:disable-next-line unified-signatures
|
660 | toBeFalsy(expectationFailOutput: any): void;
|
661 | toBeTrue(): void;
|
662 | toBeFalse(): void;
|
663 | toHaveBeenCalled(): void;
|
664 | toHaveBeenCalledBefore(expected: Func): void;
|
665 | toHaveBeenCalledWith(...params: any[]): void;
|
666 | toHaveBeenCalledOnceWith(...params: any[]): void;
|
667 | toHaveBeenCalledTimes(expected: number): void;
|
668 | toContain(expected: any): void;
|
669 | /**
|
670 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
671 | */
|
672 | // tslint:disable-next-line unified-signatures
|
673 | toContain(expected: any, expectationFailOutput: any): void;
|
674 | toBeLessThan(expected: number): void;
|
675 | /**
|
676 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
677 | */
|
678 | // tslint:disable-next-line unified-signatures
|
679 | toBeLessThan(expected: number, expectationFailOutput: any): void;
|
680 | toBeLessThanOrEqual(expected: number): void;
|
681 | /**
|
682 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
683 | */
|
684 | // tslint:disable-next-line unified-signatures
|
685 | toBeLessThanOrEqual(expected: number, expectationFailOutput: any): void;
|
686 | toBeGreaterThan(expected: number): void;
|
687 | /**
|
688 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
689 | */
|
690 | // tslint:disable-next-line unified-signatures
|
691 | toBeGreaterThan(expected: number, expectationFailOutput: any): void;
|
692 | toBeGreaterThanOrEqual(expected: number): void;
|
693 | /**
|
694 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
695 | */
|
696 | // tslint:disable-next-line unified-signatures
|
697 | toBeGreaterThanOrEqual(expected: number, expectationFailOutput: any): void;
|
698 | toBeCloseTo(expected: number, precision?: any): void;
|
699 | /**
|
700 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
701 | */
|
702 | // tslint:disable-next-line unified-signatures
|
703 | toBeCloseTo(expected: number, precision: any, expectationFailOutput: any): void;
|
704 | toThrow(expected?: any): void;
|
705 | toThrowError(message?: string | RegExp): void;
|
706 | toThrowError(expected?: new (...args: any[]) => Error, message?: string | RegExp): void;
|
707 | toThrowMatching(predicate: (thrown: any) => boolean): void;
|
708 | toBeNegativeInfinity(): void;
|
709 | /**
|
710 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
711 | */
|
712 | // tslint:disable-next-line unified-signatures
|
713 | toBeNegativeInfinity(expectationFailOutput: any): void;
|
714 | toBePositiveInfinity(): void;
|
715 | /**
|
716 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
717 | */
|
718 | // tslint:disable-next-line unified-signatures
|
719 | toBePositiveInfinity(expectationFailOutput: any): void;
|
720 | toBeInstanceOf(expected: Constructor): void;
|
721 |
|
722 | /**
|
723 | * Expect the actual value to be a DOM element that has the expected class.
|
724 | * @since 3.0.0
|
725 | * @param expected The class name to test for.
|
726 | * @example
|
727 | * var el = document.createElement('div');
|
728 | * el.className = 'foo bar baz';
|
729 | * expect(el).toHaveClass('bar');
|
730 | */
|
731 | toHaveClass(expected: string): void;
|
732 | /**
|
733 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
734 | */
|
735 | // tslint:disable-next-line unified-signatures
|
736 | toHaveClass(expected: string, expectationFailOutput: any): void;
|
737 |
|
738 | /**
|
739 | * Expect the actual size to be equal to the expected, using array-like
|
740 | * length or object keys size.
|
741 | * @since 3.6.0
|
742 | * @param expected The expected size
|
743 | * @example
|
744 | * array = [1,2];
|
745 | * expect(array).toHaveSize(2);
|
746 | */
|
747 | toHaveSize(expected: number): void;
|
748 |
|
749 | /**
|
750 | * Add some context for an expect.
|
751 | * @param message Additional context to show when the matcher fails
|
752 | */
|
753 | withContext(message: string): Matchers<T>;
|
754 |
|
755 | /**
|
756 | * Invert the matcher following this expect.
|
757 | */
|
758 | not: Matchers<T>;
|
759 | }
|
760 |
|
761 | interface ArrayLikeMatchers<T> extends Matchers<ArrayLike<T>> {
|
762 | /**
|
763 | * Expect the actual value to be `===` to the expected value.
|
764 | *
|
765 | * @param expected The expected value to compare against.
|
766 | * @example
|
767 | * expect(thing).toBe(realThing);
|
768 | */
|
769 | toBe(expected: Expected<ArrayLike<T>> | ArrayContaining<T>): void;
|
770 | /**
|
771 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
772 | */
|
773 | // tslint:disable-next-line unified-signatures
|
774 | toBe(expected: Expected<ArrayLike<T>> | ArrayContaining<T>, expectationFailOutput: any): void;
|
775 |
|
776 | /**
|
777 | * Expect the actual value to be equal to the expected, using deep equality comparison.
|
778 | * @param expected Expected value.
|
779 | * @example
|
780 | * expect(bigObject).toEqual({ "foo": ['bar', 'baz'] });
|
781 | */
|
782 | toEqual(expected: Expected<ArrayLike<T>> | ArrayContaining<T>): void;
|
783 | /**
|
784 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
785 | */
|
786 | // tslint:disable-next-line unified-signatures
|
787 | toEqual(expected: Expected<ArrayLike<T>> | ArrayContaining<T>, expectationFailOutput: any): void;
|
788 |
|
789 | toContain(expected: Expected<T>): void;
|
790 | /**
|
791 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
792 | */
|
793 | // tslint:disable-next-line unified-signatures
|
794 | toContain(expected: Expected<T>, expectationFailOutput: any): void;
|
795 |
|
796 | /**
|
797 | * Add some context for an expect.
|
798 | * @param message Additional context to show when the matcher fails.
|
799 | */
|
800 | withContext(message: string): ArrayLikeMatchers<T>;
|
801 |
|
802 | /**
|
803 | * Invert the matcher following this expect.
|
804 | */
|
805 | not: ArrayLikeMatchers<T>;
|
806 | }
|
807 |
|
808 | type MatchableArgs<Fn> = Fn extends (...args: infer P) => any ? { [K in keyof P]: Expected<P[K]> } : never;
|
809 |
|
810 | interface FunctionMatchers<Fn extends Func> extends Matchers<any> {
|
811 | /**
|
812 | * Expects the actual (a spy) to have been called with the particular arguments at least once
|
813 | * @param params The arguments to look for
|
814 | */
|
815 | toHaveBeenCalledWith(...params: MatchableArgs<Fn>): void;
|
816 |
|
817 | /**
|
818 | * Expects the actual (a spy) to have been called exactly once, and exactly with the particular arguments
|
819 | * @param params The arguments to look for
|
820 | */
|
821 | toHaveBeenCalledOnceWith(...params: MatchableArgs<Fn>): void;
|
822 |
|
823 | /**
|
824 | * Add some context for an expect.
|
825 | * @param message Additional context to show when the matcher fails.
|
826 | */
|
827 | withContext(message: string): FunctionMatchers<Fn>;
|
828 |
|
829 | /**
|
830 | * Invert the matcher following this expect.
|
831 | */
|
832 | not: FunctionMatchers<Fn>;
|
833 | }
|
834 |
|
835 | interface NothingMatcher {
|
836 | nothing(): void;
|
837 | }
|
838 |
|
839 | interface AsyncMatchers<T, U> {
|
840 | /**
|
841 | * Expect a promise to be pending, i.e. the promise is neither resolved nor rejected.
|
842 | */
|
843 | toBePending(): PromiseLike<void>;
|
844 | /**
|
845 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
846 | */
|
847 | // tslint:disable-next-line unified-signatures
|
848 | toBePending(expectationFailOutput: any): PromiseLike<void>;
|
849 |
|
850 | /**
|
851 | * Expect a promise to be resolved.
|
852 | */
|
853 | toBeResolved(): PromiseLike<void>;
|
854 | /**
|
855 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
856 | */
|
857 | // tslint:disable-next-line unified-signatures
|
858 | toBeResolved(expectationFailOutput: any): PromiseLike<void>;
|
859 |
|
860 | /**
|
861 | * Expect a promise to be rejected.
|
862 | */
|
863 | toBeRejected(): PromiseLike<void>;
|
864 | /**
|
865 | * @deprecated expectationFailOutput is deprecated. Use withContext instead.
|
866 | */
|
867 | // tslint:disable-next-line unified-signatures
|
868 | toBeRejected(expectationFailOutput: any): PromiseLike<void>;
|
869 |
|
870 | /**
|
871 | * Expect a promise to be resolved to a value equal to the expected, using deep equality comparison.
|
872 | * @param expected Value that the promise is expected to resolve to.
|
873 | */
|
874 | toBeResolvedTo(expected: Expected<T>): PromiseLike<void>;
|
875 |
|
876 | /**
|
877 | * Expect a promise to be rejected with a value equal to the expected, using deep equality comparison.
|
878 | * @param expected Value that the promise is expected to be rejected with.
|
879 | */
|
880 | toBeRejectedWith(expected: Expected<U>): PromiseLike<void>;
|
881 |
|
882 | /**
|
883 | * Expect a promise to be rejected with a value matched to the expected.
|
884 | * @param expected Error constructor the object that was thrown needs to be an instance of. If not provided, Error will be used.
|
885 | * @param message The message that should be set on the thrown Error.
|
886 | */
|
887 | toBeRejectedWithError(expected?: new (...args: any[]) => Error, message?: string | RegExp): PromiseLike<void>;
|
888 |
|
889 | /**
|
890 | * Expect a promise to be rejected with a value matched to the expected.
|
891 | * @param message The message that should be set on the thrown Error.
|
892 | */
|
893 | toBeRejectedWithError(message?: string | RegExp): PromiseLike<void>;
|
894 |
|
895 | /**
|
896 | * Add some context for an expect.
|
897 | * @param message Additional context to show when the matcher fails.
|
898 | */
|
899 | withContext(message: string): AsyncMatchers<T, U>;
|
900 |
|
901 | /**
|
902 | * Fail as soon as possible if the actual is pending. Otherwise evaluate the matcher.
|
903 | */
|
904 | already: AsyncMatchers<T, U>;
|
905 |
|
906 | /**
|
907 | * Invert the matcher following this expect.
|
908 | */
|
909 | not: AsyncMatchers<T, U>;
|
910 | }
|
911 |
|
912 | interface JasmineStartedInfo {
|
913 | totalSpecsDefined: number;
|
914 | order: Order;
|
915 | }
|
916 |
|
917 | interface CustomReportExpectation {
|
918 | matcherName: string;
|
919 | message: string;
|
920 | passed: boolean;
|
921 | stack: string;
|
922 | }
|
923 |
|
924 | interface FailedExpectation extends CustomReportExpectation {
|
925 | actual: string;
|
926 | expected: string;
|
927 | }
|
928 |
|
929 | interface PassedExpectation extends CustomReportExpectation {}
|
930 |
|
931 | interface DeprecatedExpectation {
|
932 | message: string;
|
933 | }
|
934 |
|
935 | interface SuiteResult {
|
936 | /**
|
937 | * The unique id of this spec.
|
938 | */
|
939 | id: string;
|
940 |
|
941 | /**
|
942 | * The description passed to the {@link it} that created this spec.
|
943 | */
|
944 | description: string;
|
945 |
|
946 | /**
|
947 | * The full description including all ancestors of this spec.
|
948 | */
|
949 | fullName: string;
|
950 |
|
951 | /**
|
952 | * The list of expectations that failed during execution of this spec.
|
953 | */
|
954 | failedExpectations: FailedExpectation[];
|
955 |
|
956 | /**
|
957 | * The list of deprecation warnings that occurred during execution this spec.
|
958 | */
|
959 | deprecationWarnings: DeprecatedExpectation[];
|
960 |
|
961 | /**
|
962 | * Once the spec has completed, this string represents the pass/fail status of this spec.
|
963 | */
|
964 | status: string;
|
965 |
|
966 | /**
|
967 | * The time in ms used by the spec execution, including any before/afterEach.
|
968 | */
|
969 | duration: number | null;
|
970 |
|
971 | /**
|
972 | * User-supplied properties, if any, that were set using {@link Env.setSpecProperty}
|
973 | */
|
974 | properties: { [key: string]: unknown } | null;
|
975 | }
|
976 |
|
977 | interface SpecResult extends SuiteResult {
|
978 | /**
|
979 | * The list of expectations that passed during execution of this spec.
|
980 | */
|
981 | passedExpectations: PassedExpectation[];
|
982 |
|
983 | /**
|
984 | * If the spec is pending, this will be the reason.
|
985 | */
|
986 | pendingReason: string;
|
987 | }
|
988 |
|
989 | interface JasmineDoneInfo {
|
990 | overallStatus: string;
|
991 | totalTime: number;
|
992 | incompleteReason: string;
|
993 | order: Order;
|
994 | failedExpectations: ExpectationResult[];
|
995 | deprecationWarnings: ExpectationResult[];
|
996 | }
|
997 |
|
998 | /** @deprecated use JasmineStartedInfo instead */
|
999 | type SuiteInfo = JasmineStartedInfo;
|
1000 |
|
1001 | /** @deprecated use SuiteResult or SpecResult instead */
|
1002 | type CustomReporterResult = SuiteResult & SpecResult;
|
1003 |
|
1004 | /** @deprecated use JasmineDoneInfo instead */
|
1005 | type RunDetails = JasmineDoneInfo;
|
1006 |
|
1007 | interface CustomReporter {
|
1008 | jasmineStarted?(suiteInfo: JasmineStartedInfo, done?: () => void): void | Promise<void>;
|
1009 | suiteStarted?(result: SuiteResult, done?: () => void): void | Promise<void>;
|
1010 | specStarted?(result: SpecResult, done?: () => void): void | Promise<void>;
|
1011 | specDone?(result: SpecResult, done?: () => void): void | Promise<void>;
|
1012 | suiteDone?(result: SuiteResult, done?: () => void): void | Promise<void>;
|
1013 | jasmineDone?(runDetails: JasmineDoneInfo, done?: () => void): void | Promise<void>;
|
1014 | }
|
1015 |
|
1016 | type SpecFunction = (spec?: Spec) => void;
|
1017 |
|
1018 | interface Spec {
|
1019 | new (attrs: any): any;
|
1020 |
|
1021 | id: number;
|
1022 | env: Env;
|
1023 | description: string;
|
1024 | getFullName(): string;
|
1025 | }
|
1026 |
|
1027 | interface Suite extends Spec {
|
1028 | parentSuite: Suite;
|
1029 | children: Array<Spec | Suite>;
|
1030 | }
|
1031 |
|
1032 | interface Spy<Fn extends Func = Func> {
|
1033 | (...params: Parameters<Fn>): ReturnType<Fn>;
|
1034 |
|
1035 | and: SpyAnd<Fn>;
|
1036 | calls: Calls<Fn>;
|
1037 | withArgs(...args: MatchableArgs<Fn>): Spy<Fn>;
|
1038 | }
|
1039 |
|
1040 | type SpyObj<T> = T &
|
1041 | {
|
1042 | [K in keyof T]: T[K] extends Func ? T[K] & Spy<T[K]> : T[K];
|
1043 | };
|
1044 |
|
1045 | /**
|
1046 | * Determines whether the provided function is a Jasmine spy.
|
1047 | * @since 2.0.0
|
1048 | * @param putativeSpy The function to check.
|
1049 | */
|
1050 | function isSpy(putativeSpy: Func): putativeSpy is Spy;
|
1051 |
|
1052 | /**
|
1053 | * It's like SpyObj, but doesn't verify argument/return types for functions.
|
1054 | * Useful if TS cannot correctly infer type for complex objects.
|
1055 | */
|
1056 | type NonTypedSpyObj<T> = SpyObj<{ [K in keyof T]: T[K] extends Func ? Func : T[K] }>;
|
1057 |
|
1058 | /**
|
1059 | * Obtains the promised type that a promise-returning function resolves to.
|
1060 | */
|
1061 | type PromisedReturnType<Fn extends Func> = Fn extends (...args: any[]) => PromiseLike<infer TResult>
|
1062 | ? TResult
|
1063 | : never;
|
1064 |
|
1065 | /**
|
1066 | * Obtains the type that a promise-returning function can be rejected with.
|
1067 | * This is so we can use .and.rejectWith() only for functions that return a promise.
|
1068 | */
|
1069 | type PromisedRejectType<Fn extends Function> = Fn extends (...args: any[]) => PromiseLike<unknown> ? any : never;
|
1070 |
|
1071 | interface SpyAnd<Fn extends Func> {
|
1072 | identity: string;
|
1073 |
|
1074 | /** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */
|
1075 | callThrough(): Spy<Fn>;
|
1076 | /** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */
|
1077 | returnValue(val: ReturnType<Fn>): Spy<Fn>;
|
1078 | /** By chaining the spy with and.returnValues, all calls to the function will return specific values in order until it reaches the end of the return values list. */
|
1079 | returnValues(...values: Array<ReturnType<Fn>>): Spy<Fn>;
|
1080 | /** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */
|
1081 | callFake(fn: Fn): Spy<Fn>;
|
1082 | /** Tell the spy to return a promise resolving to the specified value when invoked. */
|
1083 | resolveTo(val?: PromisedReturnType<Fn>): Spy<Fn>;
|
1084 | /** Tell the spy to return a promise rejecting with the specified value when invoked. */
|
1085 | rejectWith(val?: PromisedRejectType<Fn>): Spy<Fn>;
|
1086 | /** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */
|
1087 | throwError(msg: string | Error): Spy;
|
1088 | /** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */
|
1089 | stub(): Spy;
|
1090 | }
|
1091 |
|
1092 | interface Calls<Fn extends Func> {
|
1093 | /** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. */
|
1094 | any(): boolean;
|
1095 | /** By chaining the spy with calls.count(), will return the number of times the spy was called */
|
1096 | count(): number;
|
1097 | /** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index */
|
1098 | argsFor(index: number): Parameters<Fn>;
|
1099 | /** By chaining the spy with calls.allArgs(), will return the arguments to all calls */
|
1100 | allArgs(): ReadonlyArray<Parameters<Fn>>;
|
1101 | /** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls */
|
1102 | all(): ReadonlyArray<CallInfo<Fn>>;
|
1103 | /** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call */
|
1104 | mostRecent(): CallInfo<Fn>;
|
1105 | /** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call */
|
1106 | first(): CallInfo<Fn>;
|
1107 | /** By chaining the spy with calls.reset(), will clears all tracking for a spy */
|
1108 | reset(): void;
|
1109 | /** Set this spy to do a shallow clone of arguments passed to each invocation. */
|
1110 | saveArgumentsByValue(): void;
|
1111 | /** Get the "this" object that was passed to a specific invocation of this spy. */
|
1112 | thisFor(index: number): any;
|
1113 | }
|
1114 |
|
1115 | interface CallInfo<Fn extends Func> {
|
1116 | /** The context (the this) for the call */
|
1117 | object: any;
|
1118 | /** All arguments passed to the call */
|
1119 | args: Parameters<Fn>;
|
1120 | /** The return value of the call */
|
1121 | returnValue: ReturnType<Fn>;
|
1122 | }
|
1123 |
|
1124 | interface Util {
|
1125 | inherit(childClass: Function, parentClass: Function): any;
|
1126 | formatException(e: any): any;
|
1127 | htmlEscape(str: string): string;
|
1128 | argsToArray(args: any): any;
|
1129 | extend(destination: any, source: any): any;
|
1130 | }
|
1131 |
|
1132 | interface JsApiReporter extends CustomReporter {
|
1133 | new (): any;
|
1134 |
|
1135 | started: boolean;
|
1136 | finished: boolean;
|
1137 | runDetails: JasmineDoneInfo;
|
1138 |
|
1139 | status(): string;
|
1140 | suiteResults(index: number, length: number): SuiteResult[];
|
1141 | specResults(index: number, length: number): SpecResult[];
|
1142 | suites(): { [id: string]: SuiteResult };
|
1143 | specs(): SpecResult[];
|
1144 | executionTime(): number;
|
1145 | }
|
1146 |
|
1147 | interface Jasmine {
|
1148 | Spec: Spec;
|
1149 | clock: Clock;
|
1150 | util: Util;
|
1151 | }
|
1152 |
|
1153 | var HtmlReporter: HtmlReporter;
|
1154 | var HtmlSpecFilter: HtmlSpecFilter;
|
1155 |
|
1156 | /**
|
1157 | * Default number of milliseconds Jasmine will wait for an asynchronous spec to complete.
|
1158 | */
|
1159 | var DEFAULT_TIMEOUT_INTERVAL: number;
|
1160 |
|
1161 | /**
|
1162 | * Maximum number of array elements to display when pretty printing objects.
|
1163 | * This will also limit the number of keys and values displayed for an object.
|
1164 | * Elements past this number will be ellipised.
|
1165 | */
|
1166 | var MAX_PRETTY_PRINT_ARRAY_LENGTH: number;
|
1167 |
|
1168 | /**
|
1169 | * Maximum number of characters to display when pretty printing objects.
|
1170 | * Characters past this number will be ellipised.
|
1171 | */
|
1172 | var MAX_PRETTY_PRINT_CHARS: number;
|
1173 |
|
1174 | /**
|
1175 | * Maximum object depth the pretty printer will print to.
|
1176 | * Set this to a lower value to speed up pretty printing if you have large objects.
|
1177 | */
|
1178 | var MAX_PRETTY_PRINT_DEPTH: number;
|
1179 |
|
1180 | var version: string;
|
1181 |
|
1182 | interface JasmineOptions {
|
1183 | /**
|
1184 | * The path to the project's base directory. This can be absolute or relative
|
1185 | * to the current working directory. If it isn't specified, the current working
|
1186 | * directory will be used.
|
1187 | */
|
1188 | projectBaseDir?: string;
|
1189 | }
|
1190 |
|
1191 | interface JasmineConfig {
|
1192 | /**
|
1193 | * Whether to fail specs that contain no expectations.
|
1194 | * @default false
|
1195 | */
|
1196 | failSpecWithNoExpectations?: boolean;
|
1197 | /**
|
1198 | * An array of helper file paths or globs that match helper files. Each path or
|
1199 | * glob will be evaluated relative to the spec directory. Helpers are loaded before specs.
|
1200 | */
|
1201 | helpers?: string[];
|
1202 | /**
|
1203 | * Specifies how to load files with names ending in .js. Valid values are
|
1204 | * "require" and "import". "import" should be safe in all cases, and is
|
1205 | * required if your project contains ES modules with filenames ending in .js.
|
1206 | * @default "require"
|
1207 | */
|
1208 | jsLoader?: "require" | "import";
|
1209 | /**
|
1210 | * Whether to run specs in a random order.
|
1211 | */
|
1212 | random?: boolean;
|
1213 | /**
|
1214 | * An array of module names to load via require() at the start of execution.
|
1215 | */
|
1216 | requires?: string[];
|
1217 | /**
|
1218 | * The directory that spec files are contained in, relative to the project base directory.
|
1219 | */
|
1220 | spec_dir?: string;
|
1221 | /**
|
1222 | * An array of spec file paths or globs that match helper files. Each path
|
1223 | * or glob will be evaluated relative to the spec directory.
|
1224 | */
|
1225 | spec_files?: string[];
|
1226 | /**
|
1227 | * Whether to stop suite execution on the first spec failure.
|
1228 | */
|
1229 | stopOnSpecFailure?: boolean;
|
1230 | /**
|
1231 | * Whether to stop each spec on the first expectation failure.
|
1232 | */
|
1233 | stopSpecOnExpectationFailure?: boolean;
|
1234 | }
|
1235 |
|
1236 | interface DefaultReporterOptions {
|
1237 | timer?: any;
|
1238 | print?: (...args: any[]) => void;
|
1239 | showColors?: boolean;
|
1240 | jasmineCorePath?: string;
|
1241 | }
|
1242 | }
|
1243 |
|
1244 | declare module "jasmine" {
|
1245 | class jasmine {
|
1246 | jasmine: jasmine.Jasmine;
|
1247 | env: jasmine.Env;
|
1248 | reportersCount: number;
|
1249 | completionReporter: jasmine.CustomReporter;
|
1250 | reporter: jasmine.CustomReporter;
|
1251 | showingColors: boolean;
|
1252 | projectBaseDir: string;
|
1253 | specDir: string;
|
1254 | specFiles: string[];
|
1255 | helperFiles: string[];
|
1256 | requires: string[];
|
1257 | onCompleteCallbackAdded: boolean;
|
1258 | defaultReporterConfigured: boolean;
|
1259 |
|
1260 | constructor(options: jasmine.JasmineOptions);
|
1261 | addMatchers(matchers: jasmine.CustomMatcherFactories): void;
|
1262 | /**
|
1263 | * Add a custom reporter to the Jasmine environment.
|
1264 | */
|
1265 | addReporter(reporter: jasmine.CustomReporter): void;
|
1266 | /**
|
1267 | * Adds a spec file to the list that will be loaded when the suite is executed.
|
1268 | */
|
1269 | addSpecFile(filePath: string): void;
|
1270 | addSpecFiles(files: string[]): void;
|
1271 | addHelperFiles(files: string[]): void;
|
1272 | addRequires(files: string[]): void;
|
1273 | /**
|
1274 | * Configure the default reporter.
|
1275 | */
|
1276 | configureDefaultReporter(options: jasmine.DefaultReporterOptions): void;
|
1277 | execute(files?: string[], filterString?: string): Promise<void>;
|
1278 | exitCodeCompletion(passed: boolean): void;
|
1279 | loadConfig(config: jasmine.JasmineConfig): void;
|
1280 | loadConfigFile(configFilePath?: string): void;
|
1281 | loadHelpers(): Promise<void>;
|
1282 | loadSpecs(): Promise<void>;
|
1283 | loadRequires(): void;
|
1284 | onComplete(onCompleteCallback: (passed: boolean) => void): void;
|
1285 | /**
|
1286 | * Provide a fallback reporter if no other reporters have been specified.
|
1287 | */
|
1288 | provideFallbackReporter(reporter: jasmine.CustomReporter): void;
|
1289 | /**
|
1290 | * Clears all registered reporters.
|
1291 | */
|
1292 | clearReporters(): void;
|
1293 | /**
|
1294 | * Sets whether to randomize the order of specs.
|
1295 | */
|
1296 | randomizeTests(value: boolean): void;
|
1297 | /**
|
1298 | * Sets the random seed.
|
1299 | */
|
1300 | seed(value: number): void;
|
1301 | /**
|
1302 | * Sets whether to show colors in the console reporter.
|
1303 | */
|
1304 | showColors(value: boolean): void;
|
1305 | stopSpecOnExpectationFailure(value: boolean): void;
|
1306 | stopOnSpecFailure(value: boolean): void;
|
1307 | static ConsoleReporter(): any;
|
1308 |
|
1309 | /**
|
1310 | * The version of jasmine-core in use
|
1311 | */
|
1312 | coreVersion(): string;
|
1313 | }
|
1314 | export = jasmine;
|
1315 | }
|