1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | type ImplementationCallback = jasmine.ImplementationCallback;
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | declare function describe(description: string, specDefinitions: () => void): void;
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | declare function fdescribe(description: string, specDefinitions: () => void): void;
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | declare function xdescribe(description: string, specDefinitions: () => void): void;
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | declare function it(expectation: string, assertion?: jasmine.ImplementationCallback, timeout?: number): void;
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | declare function fit(expectation: string, assertion?: jasmine.ImplementationCallback, timeout?: number): void;
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | declare function xit(expectation: string, assertion?: jasmine.ImplementationCallback, timeout?: number): void;
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | declare function pending(reason?: string): void;
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 | declare function beforeEach(action: jasmine.ImplementationCallback, timeout?: number): void;
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | declare function afterEach(action: jasmine.ImplementationCallback, timeout?: number): void;
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 | declare function beforeAll(action: jasmine.ImplementationCallback, timeout?: number): void;
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 | declare function afterAll(action: jasmine.ImplementationCallback, timeout?: number): void;
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 | declare function expect(spy: Function): jasmine.Matchers<any>;
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 | declare function expect<T>(actual: ArrayLike<T>): jasmine.ArrayLikeMatchers<T>;
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 | declare function expect<T>(actual: T): jasmine.Matchers<T>;
|
130 |
|
131 |
|
132 |
|
133 |
|
134 | declare function expect(): jasmine.NothingMatcher;
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 | declare function expectAsync<T, U>(actual: T|PromiseLike<T>): jasmine.AsyncMatchers<T, U>;
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 | declare function fail(e?: any): void;
|
151 |
|
152 |
|
153 |
|
154 |
|
155 | interface DoneFn extends Function {
|
156 | (): void;
|
157 |
|
158 |
|
159 | fail: (message?: Error | string) => void;
|
160 | }
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 | declare function spyOn<T>(object: T, method: keyof T): jasmine.Spy;
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 | declare function spyOnProperty<T>(object: T, property: keyof T, accessType?: 'get' | 'set'): jasmine.Spy;
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 | declare function spyOnAllFunctions<T>(object: T): jasmine.SpyObj<T>;
|
182 |
|
183 | declare function runs(asyncMethod: Function): void;
|
184 | declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void;
|
185 | declare function waits(timeout?: number): void;
|
186 |
|
187 | declare namespace jasmine {
|
188 | type Func = (...args: any[]) => any;
|
189 |
|
190 |
|
191 |
|
192 | type Constructor = Function & { prototype: any };
|
193 |
|
194 | type ImplementationCallback = (() => PromiseLike<any>) | ((done: DoneFn) => void);
|
195 |
|
196 | type ExpectedRecursive<T> = T | ObjectContaining<T> | AsymmetricMatcher<any> | {
|
197 | [K in keyof T]: ExpectedRecursive<T[K]> | Any;
|
198 | };
|
199 | type Expected<T> = T | ObjectContaining<T> | AsymmetricMatcher<any> | Any | Spy | {
|
200 | [K in keyof T]: ExpectedRecursive<T[K]>;
|
201 | };
|
202 | type SpyObjMethodNames<T = undefined> =
|
203 | T extends undefined ?
|
204 | (ReadonlyArray<string> | { [methodName: string]: any }) :
|
205 | (ReadonlyArray<keyof T> | { [P in keyof T]?: T[P] extends Func ? ReturnType<T[P]> : any });
|
206 |
|
207 | type SpyObjPropertyNames<T = undefined> =
|
208 | T extends undefined ?
|
209 | (ReadonlyArray<string> | { [propertyName: string]: any }) :
|
210 | (ReadonlyArray<keyof T> | { [P in keyof T]?: T[P] });
|
211 |
|
212 | /**
|
213 | * Configuration that can be used when configuring Jasmine via {@link jasmine.Env.configure}
|
214 | */
|
215 | interface EnvConfiguration {
|
216 | random?: boolean;
|
217 | seed?: number;
|
218 | failFast?: boolean;
|
219 | failSpecWithNoExpectations?: boolean;
|
220 | oneFailurePerSpec?: boolean;
|
221 | hideDisabled?: boolean;
|
222 | specFilter?: Function;
|
223 | Promise?: Function;
|
224 | }
|
225 |
|
226 | function clock(): Clock;
|
227 |
|
228 | var matchersUtil: MatchersUtil;
|
229 |
|
230 | /**
|
231 | * That will succeed if the actual value being compared is an instance of the specified class/constructor.
|
232 | */
|
233 | function any(aclass: Constructor | Symbol): AsymmetricMatcher<any>;
|
234 |
|
235 | /**
|
236 | * That will succeed if the actual value being compared is not `null` and not `undefined`.
|
237 | */
|
238 | function anything(): AsymmetricMatcher<any>;
|
239 |
|
240 | /**
|
241 | * That will succeed if the actual value being compared is `true` or anything truthy.
|
242 | * @since 3.1.0
|
243 | */
|
244 | function truthy(): AsymmetricMatcher<any>;
|
245 |
|
246 | /**
|
247 | * That will succeed if the actual value being compared is `null`, `undefined`, `0`, `false` or anything falsey.
|
248 | * @since 3.1.0
|
249 | */
|
250 | function falsy(): AsymmetricMatcher<any>;
|
251 |
|
252 | /**
|
253 | * That will succeed if the actual value being compared is empty.
|
254 | * @since 3.1.0
|
255 | */
|
256 | function empty(): AsymmetricMatcher<any>;
|
257 |
|
258 | /**
|
259 | * That will succeed if the actual value being compared is not empty.
|
260 | * @since 3.1.0
|
261 | */
|
262 | function notEmpty(): AsymmetricMatcher<any>;
|
263 |
|
264 | function arrayContaining<T>(sample: ArrayLike<T>): ArrayContaining<T>;
|
265 | function arrayWithExactContents<T>(sample: ArrayLike<T>): ArrayContaining<T>;
|
266 | function objectContaining<T>(sample: {[K in keyof T]?: ExpectedRecursive<T[K]>}): ObjectContaining<T>;
|
267 |
|
268 | function setDefaultSpyStrategy(and: SpyAnd): void;
|
269 | function createSpy(name?: string, originalFn?: Function): Spy;
|
270 | function createSpyObj(baseName: string, methodNames: SpyObjMethodNames, propertyNames?: SpyObjPropertyNames): any;
|
271 | function createSpyObj<T>(baseName: string, methodNames: SpyObjMethodNames<T>, propertyNames?: SpyObjPropertyNames<T>): SpyObj<T>;
|
272 | function createSpyObj(methodNames: SpyObjMethodNames, propertyNames?: SpyObjPropertyNames): any;
|
273 | function createSpyObj<T>(methodNames: SpyObjMethodNames<T>, propertyNames?: SpyObjPropertyNames<T>): SpyObj<T>;
|
274 |
|
275 | function pp(value: any): string;
|
276 |
|
277 | function getEnv(): Env;
|
278 |
|
279 | function addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
|
280 |
|
281 | function addMatchers(matchers: CustomMatcherFactories): void;
|
282 | function addAsyncMatchers(matchers: CustomAsyncMatcherFactories): void;
|
283 |
|
284 | function stringMatching(str: string | RegExp): AsymmetricMatcher<string>;
|
285 |
|
286 | function formatErrorMsg(domain: string, usage: string): (msg: string) => string;
|
287 |
|
288 | interface Any extends AsymmetricMatcher<any> {
|
289 | (...params: any[]): any;
|
290 | new (expectedClass: any): any;
|
291 |
|
292 | jasmineMatches(other: any): boolean;
|
293 | jasmineToString(): string;
|
294 | }
|
295 |
|
296 | interface AsymmetricMatcher<TValue> {
|
297 | asymmetricMatch(other: TValue, customTesters: ReadonlyArray<CustomEqualityTester>): boolean;
|
298 | jasmineToString?(): string;
|
299 | }
|
300 |
|
301 |
|
302 | interface ArrayLike<T> {
|
303 | length: number;
|
304 | [n: number]: T;
|
305 | }
|
306 |
|
307 | interface ArrayContaining<T> extends AsymmetricMatcher<any> {
|
308 | new?(sample: ArrayLike<T>): ArrayLike<T>;
|
309 | }
|
310 |
|
311 | interface ObjectContaining<T> extends AsymmetricMatcher<any> {
|
312 | new?(sample: {[K in keyof T]?: any}): {[K in keyof T]?: any};
|
313 |
|
314 | jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
|
315 | jasmineToString?(): string;
|
316 | }
|
317 |
|
318 | interface Block {
|
319 | new (env: Env, func: SpecFunction, spec: Spec): any;
|
320 |
|
321 | execute(onComplete: () => void): void;
|
322 | }
|
323 |
|
324 | interface WaitsBlock extends Block {
|
325 | new (env: Env, timeout: number, spec: Spec): any;
|
326 | }
|
327 |
|
328 | interface WaitsForBlock extends Block {
|
329 | new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any;
|
330 | }
|
331 |
|
332 | interface Clock {
|
333 | install(): void;
|
334 | uninstall(): void;
|
335 |
|
336 | tick(ms: number): void;
|
337 | mockDate(date?: Date): void;
|
338 | withMock(func: () => void): void;
|
339 | }
|
340 |
|
341 | type CustomEqualityTester = (first: any, second: any) => boolean | void;
|
342 |
|
343 | interface CustomMatcher {
|
344 | compare<T>(actual: T, expected: T, ...args: any[]): CustomMatcherResult;
|
345 | compare(actual: any, ...expected: any[]): CustomMatcherResult;
|
346 | negativeCompare?<T>(actual: T, expected: T, ...args: any[]): CustomMatcherResult;
|
347 | negativeCompare?(actual: any, ...expected: any[]): CustomMatcherResult;
|
348 | }
|
349 |
|
350 | interface CustomAsyncMatcher {
|
351 | compare<T>(actual: T, expected: T, ...args: any[]): Promise<CustomMatcherResult>;
|
352 | compare(actual: any, ...expected: any[]): Promise<CustomMatcherResult>;
|
353 | negativeCompare?<T>(actual: T, expected: T, ...args: any[]): Promise<CustomMatcherResult>;
|
354 | negativeCompare?(actual: any, ...expected: any[]): Promise<CustomMatcherResult>;
|
355 | }
|
356 |
|
357 | type CustomMatcherFactory = (util: MatchersUtil, customEqualityTesters: ReadonlyArray<CustomEqualityTester>) => CustomMatcher;
|
358 |
|
359 | type CustomAsyncMatcherFactory = (util: MatchersUtil, customEqualityTesters: ReadonlyArray<CustomEqualityTester>) => CustomAsyncMatcher;
|
360 |
|
361 | interface CustomMatcherFactories {
|
362 | [name: string]: CustomMatcherFactory;
|
363 | }
|
364 |
|
365 | interface CustomAsyncMatcherFactories {
|
366 | [name: string]: CustomAsyncMatcherFactory;
|
367 | }
|
368 |
|
369 | interface CustomMatcherResult {
|
370 | pass: boolean;
|
371 | message?: string;
|
372 | }
|
373 |
|
374 | interface MatchersUtil {
|
375 | equals(a: any, b: any, customTesters?: ReadonlyArray<CustomEqualityTester>): boolean;
|
376 | contains<T>(haystack: ArrayLike<T> | string, needle: any, customTesters?: ReadonlyArray<CustomEqualityTester>): boolean;
|
377 | buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: any[]): string;
|
378 | }
|
379 |
|
380 | interface Env {
|
381 | currentSpec: Spec;
|
382 |
|
383 | matchersClass: Matchers<any>;
|
384 |
|
385 | version(): any;
|
386 | versionString(): string;
|
387 | nextSpecId(): number;
|
388 | addReporter(reporter: Reporter | CustomReporter): void;
|
389 | execute(): void;
|
390 | describe(description: string, specDefinitions: () => void): Suite;
|
391 |
|
392 | beforeEach(beforeEachFunction: ImplementationCallback, timeout?: number): void;
|
393 | beforeAll(beforeAllFunction: ImplementationCallback, timeout?: number): void;
|
394 | currentRunner(): Runner;
|
395 | afterEach(afterEachFunction: ImplementationCallback, timeout?: number): void;
|
396 | afterAll(afterAllFunction: ImplementationCallback, timeout?: number): void;
|
397 | xdescribe(desc: string, specDefinitions: () => void): XSuite;
|
398 | it(description: string, func: () => void): Spec;
|
399 |
|
400 | xit(desc: string, func: () => void): XSpec;
|
401 | compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean;
|
402 | compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
|
403 | equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
|
404 | contains_(haystack: any, needle: any): boolean;
|
405 | addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
|
406 | addMatchers(matchers: CustomMatcherFactories): void;
|
407 | specFilter(spec: Spec): boolean;
|
408 | |
409 |
|
410 |
|
411 | throwOnExpectationFailure(value: boolean): void;
|
412 | |
413 |
|
414 |
|
415 | stopOnSpecFailure(value: boolean): void;
|
416 | |
417 |
|
418 |
|
419 | seed(seed: string | number): string | number;
|
420 | provideFallbackReporter(reporter: Reporter): void;
|
421 | throwingExpectationFailures(): boolean;
|
422 | allowRespy(allow: boolean): void;
|
423 | randomTests(): boolean;
|
424 | |
425 |
|
426 |
|
427 | randomizeTests(b: boolean): void;
|
428 | clearReporters(): void;
|
429 | configure(configuration: EnvConfiguration): void;
|
430 | }
|
431 |
|
432 | interface FakeTimer {
|
433 | new (): any;
|
434 |
|
435 | reset(): void;
|
436 | tick(millis: number): void;
|
437 | runFunctionsWithinRange(oldMillis: number, nowMillis: number): void;
|
438 | scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void;
|
439 | }
|
440 |
|
441 | interface HtmlReporter {
|
442 | new (): any;
|
443 | }
|
444 |
|
445 | interface HtmlSpecFilter {
|
446 | new (): any;
|
447 | }
|
448 |
|
449 | interface Result {
|
450 | type: string;
|
451 | }
|
452 |
|
453 | interface NestedResults extends Result {
|
454 | description: string;
|
455 |
|
456 | totalCount: number;
|
457 | passedCount: number;
|
458 | failedCount: number;
|
459 |
|
460 | skipped: boolean;
|
461 |
|
462 | rollupCounts(result: NestedResults): void;
|
463 | log(values: any): void;
|
464 | getItems(): Result[];
|
465 | addResult(result: Result): void;
|
466 | passed(): boolean;
|
467 | }
|
468 |
|
469 | interface MessageResult extends Result {
|
470 | values: any;
|
471 | trace: Trace;
|
472 | }
|
473 |
|
474 | interface ExpectationResult extends Result {
|
475 | matcherName: string;
|
476 | passed(): boolean;
|
477 | expected: any;
|
478 | actual: any;
|
479 | message: string;
|
480 | trace: Trace;
|
481 | }
|
482 |
|
483 | interface Order {
|
484 | new (options: { random: boolean, seed: string }): any;
|
485 | random: boolean;
|
486 | seed: string;
|
487 | sort<T>(items: T[]): T[];
|
488 | }
|
489 |
|
490 | namespace errors {
|
491 | class ExpectationFailed extends Error {
|
492 | constructor();
|
493 |
|
494 | stack: any;
|
495 | }
|
496 | }
|
497 |
|
498 | interface TreeProcessor {
|
499 | new (attrs: any): any;
|
500 | execute: (done: Function) => void;
|
501 | processTree(): any;
|
502 | }
|
503 |
|
504 | interface Trace {
|
505 | name: string;
|
506 | message: string;
|
507 | stack: any;
|
508 | }
|
509 |
|
510 | interface PrettyPrinter {
|
511 | new (): any;
|
512 |
|
513 | format(value: any): void;
|
514 | iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void;
|
515 | emitScalar(value: any): void;
|
516 | emitString(value: string): void;
|
517 | emitArray(array: any[]): void;
|
518 | emitObject(obj: any): void;
|
519 | append(value: any): void;
|
520 | }
|
521 |
|
522 | interface StringPrettyPrinter extends PrettyPrinter {
|
523 | }
|
524 |
|
525 | interface Queue {
|
526 | new (env: any): any;
|
527 |
|
528 | env: Env;
|
529 | ensured: boolean[];
|
530 | blocks: Block[];
|
531 | running: boolean;
|
532 | index: number;
|
533 | offset: number;
|
534 | abort: boolean;
|
535 |
|
536 | addBefore(block: Block, ensure?: boolean): void;
|
537 | add(block: any, ensure?: boolean): void;
|
538 | insertNext(block: any, ensure?: boolean): void;
|
539 | start(onComplete?: () => void): void;
|
540 | isRunning(): boolean;
|
541 | next_(): void;
|
542 | results(): NestedResults;
|
543 | }
|
544 |
|
545 | interface Matchers<T> {
|
546 | new (env: Env, actual: T, spec: Env, isNot?: boolean): any;
|
547 |
|
548 | env: Env;
|
549 | actual: T;
|
550 | spec: Env;
|
551 | isNot?: boolean;
|
552 | message(): any;
|
553 |
|
554 | |
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 | toBe(expected: Expected<T>, expectationFailOutput?: any): boolean;
|
563 |
|
564 | |
565 |
|
566 |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 | toEqual(expected: Expected<T>, expectationFailOutput?: any): boolean;
|
572 |
|
573 | |
574 |
|
575 |
|
576 |
|
577 |
|
578 |
|
579 |
|
580 | toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean;
|
581 |
|
582 | toBeDefined(expectationFailOutput?: any): boolean;
|
583 | toBeUndefined(expectationFailOutput?: any): boolean;
|
584 | toBeNull(expectationFailOutput?: any): boolean;
|
585 | toBeNaN(): boolean;
|
586 | toBeTruthy(expectationFailOutput?: any): boolean;
|
587 | toBeFalsy(expectationFailOutput?: any): boolean;
|
588 | toBeTrue(): boolean;
|
589 | toBeFalse(): boolean;
|
590 | toHaveBeenCalled(): boolean;
|
591 | toHaveBeenCalledBefore(expected: Spy): boolean;
|
592 | toHaveBeenCalledWith(...params: any[]): boolean;
|
593 | toHaveBeenCalledTimes(expected: number): boolean;
|
594 | toContain(expected: any, expectationFailOutput?: any): boolean;
|
595 | toBeLessThan(expected: number, expectationFailOutput?: any): boolean;
|
596 | toBeLessThanOrEqual(expected: number, expectationFailOutput?: any): boolean;
|
597 | toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean;
|
598 | toBeGreaterThanOrEqual(expected: number, expectationFailOutput?: any): boolean;
|
599 | toBeCloseTo(expected: number, precision?: any, expectationFailOutput?: any): boolean;
|
600 | toThrow(expected?: any): boolean;
|
601 | toThrowError(message?: string | RegExp): boolean;
|
602 | toThrowError(expected?: new (...args: any[]) => Error, message?: string | RegExp): boolean;
|
603 | toThrowMatching(predicate: (thrown: any) => boolean): boolean;
|
604 | toBeNegativeInfinity(expectationFailOutput?: any): boolean;
|
605 | toBePositiveInfinity(expectationFailOutput?: any): boolean;
|
606 | toBeInstanceOf(expected: Constructor): boolean;
|
607 |
|
608 | |
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 | toHaveClass(expected: string, expectationFailOutput?: any): boolean;
|
618 |
|
619 | |
620 |
|
621 |
|
622 |
|
623 | withContext(message: string): Matchers<T>;
|
624 |
|
625 | |
626 |
|
627 |
|
628 | not: Matchers<T>;
|
629 | }
|
630 |
|
631 | interface ArrayLikeMatchers<T> extends Matchers<ArrayLike<T>> {
|
632 | |
633 |
|
634 |
|
635 |
|
636 |
|
637 |
|
638 |
|
639 |
|
640 | toBe(expected: Expected<ArrayLike<T>> | ArrayContaining<T>, expectationFailOutput?: any): boolean;
|
641 |
|
642 | |
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 | toEqual(expected: Expected<ArrayLike<T>> | ArrayContaining<T>, expectationFailOutput?: any): boolean;
|
650 |
|
651 | toContain(expected: Expected<T>, expectationFailOutput?: any): boolean;
|
652 |
|
653 | |
654 |
|
655 |
|
656 |
|
657 | withContext(message: string): ArrayLikeMatchers<T>;
|
658 |
|
659 | |
660 |
|
661 |
|
662 | not: ArrayLikeMatchers<T>;
|
663 | }
|
664 |
|
665 | interface NothingMatcher {
|
666 | nothing(): void;
|
667 | }
|
668 |
|
669 | interface AsyncMatchers<T, U> {
|
670 | |
671 |
|
672 |
|
673 |
|
674 | toBeResolved(expectationFailOutput?: any): PromiseLike<void>;
|
675 |
|
676 | |
677 |
|
678 |
|
679 |
|
680 | toBeRejected(expectationFailOutput?: any): PromiseLike<void>;
|
681 |
|
682 | |
683 |
|
684 |
|
685 |
|
686 | toBeResolvedTo(expected: Expected<T>): PromiseLike<void>;
|
687 |
|
688 | |
689 |
|
690 |
|
691 |
|
692 | toBeRejectedWith(expected: Expected<U>): PromiseLike<void>;
|
693 |
|
694 | |
695 |
|
696 |
|
697 |
|
698 |
|
699 | toBeRejectedWithError(expected?: new (...args: any[]) => Error, message?: string | RegExp): PromiseLike<void>;
|
700 |
|
701 | |
702 |
|
703 |
|
704 |
|
705 | toBeRejectedWithError(message?: string | RegExp): PromiseLike<void>;
|
706 |
|
707 | |
708 |
|
709 |
|
710 |
|
711 | withContext(message: string): AsyncMatchers<T, U>;
|
712 |
|
713 | |
714 |
|
715 |
|
716 | not: AsyncMatchers<T, U>;
|
717 | }
|
718 |
|
719 | interface Reporter {
|
720 | reportRunnerStarting(runner: Runner): void;
|
721 | reportRunnerResults(runner: Runner): void;
|
722 | reportSuiteResults(suite: Suite): void;
|
723 | reportSpecStarting(spec: Spec): void;
|
724 | reportSpecResults(spec: Spec): void;
|
725 | log(str: string): void;
|
726 | }
|
727 |
|
728 | interface MultiReporter extends Reporter {
|
729 | addReporter(reporter: Reporter): void;
|
730 | }
|
731 |
|
732 | interface SuiteInfo {
|
733 | totalSpecsDefined: number;
|
734 | }
|
735 |
|
736 | interface CustomReportExpectation {
|
737 | matcherName: string;
|
738 | message: string;
|
739 | passed: boolean;
|
740 | stack: string;
|
741 | }
|
742 |
|
743 | interface FailedExpectation extends CustomReportExpectation {
|
744 | actual: string;
|
745 | expected: string;
|
746 | }
|
747 |
|
748 | interface PassedExpectation extends CustomReportExpectation {
|
749 | }
|
750 |
|
751 | interface CustomReporterResult {
|
752 | description: string;
|
753 | failedExpectations?: FailedExpectation[];
|
754 | fullName: string;
|
755 | id: string;
|
756 | passedExpectations?: PassedExpectation[];
|
757 | pendingReason?: string;
|
758 | status?: string;
|
759 | }
|
760 |
|
761 | interface RunDetails {
|
762 | failedExpectations: ExpectationResult[];
|
763 | order: Order;
|
764 | }
|
765 |
|
766 | interface CustomReporter {
|
767 | jasmineStarted?(suiteInfo: SuiteInfo): void;
|
768 | suiteStarted?(result: CustomReporterResult): void;
|
769 | specStarted?(result: CustomReporterResult): void;
|
770 | specDone?(result: CustomReporterResult): void;
|
771 | suiteDone?(result: CustomReporterResult): void;
|
772 | jasmineDone?(runDetails: RunDetails): void;
|
773 | }
|
774 |
|
775 | interface Runner {
|
776 | new (env: Env): any;
|
777 |
|
778 | execute(): void;
|
779 | beforeEach(beforeEachFunction: SpecFunction): void;
|
780 | afterEach(afterEachFunction: SpecFunction): void;
|
781 | beforeAll(beforeAllFunction: SpecFunction): void;
|
782 | afterAll(afterAllFunction: SpecFunction): void;
|
783 | finishCallback(): void;
|
784 | addSuite(suite: Suite): void;
|
785 | add(block: Block): void;
|
786 | specs(): Spec[];
|
787 | suites(): Suite[];
|
788 | topLevelSuites(): Suite[];
|
789 | results(): NestedResults;
|
790 | }
|
791 |
|
792 | type SpecFunction = (spec?: Spec) => void;
|
793 |
|
794 | interface SuiteOrSpec {
|
795 | id: number;
|
796 | env: Env;
|
797 | description: string;
|
798 | queue: Queue;
|
799 | }
|
800 |
|
801 | interface Spec extends SuiteOrSpec {
|
802 | new (env: Env, suite: Suite, description: string): any;
|
803 |
|
804 | suite: Suite;
|
805 |
|
806 | afterCallbacks: SpecFunction[];
|
807 | spies_: Spy[];
|
808 |
|
809 | results_: NestedResults;
|
810 | matchersClass: Matchers<any>;
|
811 |
|
812 | getFullName(): string;
|
813 | results(): NestedResults;
|
814 | log(arguments: any): any;
|
815 | runs(func: SpecFunction): Spec;
|
816 | addToQueue(block: Block): void;
|
817 | addMatcherResult(result: Result): void;
|
818 | getResult(): any;
|
819 | expect(actual: any): any;
|
820 | waits(timeout: number): Spec;
|
821 | waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec;
|
822 | fail(e?: any): void;
|
823 | getMatchersClass_(): Matchers<any>;
|
824 | addMatchers(matchersPrototype: CustomMatcherFactories): void;
|
825 | finishCallback(): void;
|
826 | finish(onComplete?: () => void): void;
|
827 | after(doAfter: SpecFunction): void;
|
828 | execute(onComplete?: () => void, enabled?: boolean): any;
|
829 | addBeforesAndAftersToQueue(): void;
|
830 | explodes(): void;
|
831 | spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy;
|
832 | spyOnProperty(object: any, property: string, accessType?: 'get' | 'set'): Spy;
|
833 | spyOnAllFunctions(object: any): Spy;
|
834 |
|
835 | removeAllSpies(): void;
|
836 | throwOnExpectationFailure: boolean;
|
837 | }
|
838 |
|
839 | interface XSpec {
|
840 | id: number;
|
841 | runs(): void;
|
842 | }
|
843 |
|
844 | interface Suite extends SuiteOrSpec {
|
845 | new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any;
|
846 |
|
847 | parentSuite: Suite;
|
848 |
|
849 | getFullName(): string;
|
850 | finish(onComplete?: () => void): void;
|
851 | beforeEach(beforeEachFunction: SpecFunction): void;
|
852 | afterEach(afterEachFunction: SpecFunction): void;
|
853 | beforeAll(beforeAllFunction: SpecFunction): void;
|
854 | afterAll(afterAllFunction: SpecFunction): void;
|
855 | results(): NestedResults;
|
856 | add(suiteOrSpec: SuiteOrSpec): void;
|
857 | specs(): Spec[];
|
858 | suites(): Suite[];
|
859 | children(): any[];
|
860 | execute(onComplete?: () => void): void;
|
861 | }
|
862 |
|
863 | interface XSuite {
|
864 | execute(): void;
|
865 | }
|
866 |
|
867 | interface Spy {
|
868 | (...params: any[]): any;
|
869 |
|
870 | and: SpyAnd;
|
871 | calls: Calls;
|
872 | withArgs(...args: any[]): Spy;
|
873 | }
|
874 |
|
875 | type SpyObj<T> = T & {
|
876 | [K in keyof T]: T[K] extends Function ? T[K] & Spy : T[K];
|
877 | };
|
878 |
|
879 | interface SpyAnd {
|
880 | identity: string;
|
881 |
|
882 |
|
883 | callThrough(): Spy;
|
884 |
|
885 | returnValue(val: any): Spy;
|
886 |
|
887 | returnValues(...values: any[]): Spy;
|
888 |
|
889 | callFake(fn: Function): Spy;
|
890 |
|
891 | resolveTo(val?: any): Spy;
|
892 |
|
893 | rejectWith(val?: any): Spy;
|
894 |
|
895 | throwError(msg: string|Error): Spy;
|
896 |
|
897 | stub(): Spy;
|
898 | }
|
899 |
|
900 | interface Calls {
|
901 |
|
902 | any(): boolean;
|
903 |
|
904 | count(): number;
|
905 |
|
906 | argsFor(index: number): any[];
|
907 |
|
908 | allArgs(): any[];
|
909 |
|
910 | all(): CallInfo[];
|
911 |
|
912 | mostRecent(): CallInfo;
|
913 |
|
914 | first(): CallInfo;
|
915 |
|
916 | reset(): void;
|
917 |
|
918 | saveArgumentsByValue(): void;
|
919 | }
|
920 |
|
921 | interface CallInfo {
|
922 |
|
923 | object: any;
|
924 |
|
925 | args: any[];
|
926 |
|
927 | returnValue: any;
|
928 | }
|
929 |
|
930 | interface Util {
|
931 | inherit(childClass: Function, parentClass: Function): any;
|
932 | formatException(e: any): any;
|
933 | htmlEscape(str: string): string;
|
934 | argsToArray(args: any): any;
|
935 | extend(destination: any, source: any): any;
|
936 | }
|
937 |
|
938 | interface JsApiReporter extends Reporter {
|
939 | started: boolean;
|
940 | finished: boolean;
|
941 | result: any;
|
942 | messages: any;
|
943 | runDetails: RunDetails;
|
944 |
|
945 | new (): any;
|
946 |
|
947 | suites(): Suite[];
|
948 | summarize_(suiteOrSpec: SuiteOrSpec): any;
|
949 | results(): any;
|
950 | resultsForSpec(specId: any): any;
|
951 | log(str: any): any;
|
952 | resultsForSpecs(specIds: any): any;
|
953 | summarizeResult_(result: any): any;
|
954 | }
|
955 |
|
956 | interface Jasmine {
|
957 | Spec: Spec;
|
958 | clock: Clock;
|
959 | util: Util;
|
960 | }
|
961 |
|
962 | var HtmlReporter: HtmlReporter;
|
963 | var HtmlSpecFilter: HtmlSpecFilter;
|
964 |
|
965 | |
966 |
|
967 |
|
968 | var DEFAULT_TIMEOUT_INTERVAL: number;
|
969 |
|
970 | |
971 |
|
972 |
|
973 |
|
974 |
|
975 | var MAX_PRETTY_PRINT_ARRAY_LENGTH: number;
|
976 |
|
977 | |
978 |
|
979 |
|
980 |
|
981 | var MAX_PRETTY_PRINT_CHARS: number;
|
982 |
|
983 | |
984 |
|
985 |
|
986 |
|
987 | var MAX_PRETTY_PRINT_DEPTH: number;
|
988 | }
|
989 |
|
990 | declare module "jasmine" {
|
991 | class jasmine {
|
992 | constructor(options: any);
|
993 | jasmine: jasmine.Jasmine;
|
994 | addMatchers(matchers: jasmine.CustomMatcherFactories): void;
|
995 | addReporter(reporter: jasmine.Reporter): void;
|
996 | addSpecFile(filePath: string): void;
|
997 | addSpecFiles(files: string[]): void;
|
998 | configureDefaultReporter(options: any, ...args: any[]): void;
|
999 | execute(files?: string[], filterString?: string): any;
|
1000 | exitCodeCompletion(passed: any): void;
|
1001 | loadConfig(config: any): void;
|
1002 | loadConfigFile(configFilePath: any): void;
|
1003 | loadHelpers(): void;
|
1004 | loadSpecs(): void;
|
1005 | onComplete(onCompleteCallback: (passed: boolean) => void): void;
|
1006 | provideFallbackReporter(reporter: jasmine.Reporter): void;
|
1007 | randomizeTests(value?: any): boolean;
|
1008 | seed(value: any): void;
|
1009 | showColors(value: any): void;
|
1010 | stopSpecOnExpectationFailure(value: any): void;
|
1011 | static ConsoleReporter(): any;
|
1012 | env: jasmine.Env;
|
1013 | reportersCount: number;
|
1014 | completionReporter: jasmine.CustomReporter;
|
1015 | reporter: jasmine.CustomReporter;
|
1016 | coreVersion(): string;
|
1017 | showingColors: boolean;
|
1018 | projectBaseDir: string;
|
1019 | printDeprecation(): void;
|
1020 | specFiles: string[];
|
1021 | helperFiles: string[];
|
1022 | }
|
1023 | export = jasmine;
|
1024 | }
|