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