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 name of the file the suite was defined in.
|
985 | */
|
986 | filename: string;
|
987 |
|
988 | /**
|
989 | * The list of expectations that failed during execution of this spec.
|
990 | */
|
991 | failedExpectations: FailedExpectation[];
|
992 |
|
993 | /**
|
994 | * The list of deprecation warnings that occurred during execution this spec.
|
995 | */
|
996 | deprecationWarnings: DeprecatedExpectation[];
|
997 |
|
998 | /**
|
999 | * Once the spec has completed, this string represents the pass/fail status of this spec.
|
1000 | */
|
1001 | status: string;
|
1002 |
|
1003 | /**
|
1004 | * The time in ms used by the spec execution, including any before/afterEach.
|
1005 | */
|
1006 | duration: number | null;
|
1007 |
|
1008 | /**
|
1009 | * User-supplied properties, if any, that were set using {@link Env.setSpecProperty}
|
1010 | */
|
1011 | properties: { [key: string]: unknown } | null;
|
1012 | }
|
1013 |
|
1014 | interface SpecResult extends SuiteResult {
|
1015 | /**
|
1016 | * The list of expectations that passed during execution of this spec.
|
1017 | */
|
1018 | passedExpectations: PassedExpectation[];
|
1019 |
|
1020 | /**
|
1021 | * If the spec is pending, this will be the reason.
|
1022 | */
|
1023 | pendingReason: string;
|
1024 |
|
1025 | debugLogs: DebugLogEntry[] | null;
|
1026 | }
|
1027 |
|
1028 | interface DebugLogEntry {
|
1029 | message: String;
|
1030 | timestamp: number;
|
1031 | }
|
1032 |
|
1033 | interface JasmineDoneInfo {
|
1034 | overallStatus: string;
|
1035 | totalTime: number;
|
1036 | incompleteReason: string;
|
1037 | order: Order;
|
1038 | failedExpectations: ExpectationResult[];
|
1039 | deprecationWarnings: ExpectationResult[];
|
1040 | }
|
1041 |
|
1042 | /** @deprecated use JasmineStartedInfo instead */
|
1043 | type SuiteInfo = JasmineStartedInfo;
|
1044 |
|
1045 | /** @deprecated use SuiteResult or SpecResult instead */
|
1046 | type CustomReporterResult = SuiteResult & SpecResult;
|
1047 |
|
1048 | /** @deprecated use JasmineDoneInfo instead */
|
1049 | type RunDetails = JasmineDoneInfo;
|
1050 |
|
1051 | interface CustomReporter {
|
1052 | jasmineStarted?(suiteInfo: JasmineStartedInfo, done?: () => void): void | Promise<void>;
|
1053 | suiteStarted?(result: SuiteResult, done?: () => void): void | Promise<void>;
|
1054 | specStarted?(result: SpecResult, done?: () => void): void | Promise<void>;
|
1055 | specDone?(result: SpecResult, done?: () => void): void | Promise<void>;
|
1056 | suiteDone?(result: SuiteResult, done?: () => void): void | Promise<void>;
|
1057 | jasmineDone?(runDetails: JasmineDoneInfo, done?: () => void): void | Promise<void>;
|
1058 | }
|
1059 |
|
1060 | interface SpecFilter {
|
1061 | /**
|
1062 | * A function that takes a spec and returns true if it should be executed or false if it should be skipped.
|
1063 | * @param spec The spec that the filter is being applied to
|
1064 | */
|
1065 | (spec: Spec): boolean;
|
1066 | }
|
1067 |
|
1068 | /** @deprecated Please use `SpecFilter` instead of `SpecFunction`. */
|
1069 | type SpecFunction = (spec?: Spec) => void;
|
1070 |
|
1071 | interface Spec {
|
1072 | new(attrs: any): any;
|
1073 |
|
1074 | readonly id: string;
|
1075 | env: Env;
|
1076 | readonly description: string;
|
1077 | getFullName(): string;
|
1078 | }
|
1079 |
|
1080 | interface Suite extends Spec {
|
1081 | parentSuite: Suite;
|
1082 | children: Array<Spec | Suite>;
|
1083 | }
|
1084 |
|
1085 | interface Spy<Fn extends Func = Func> {
|
1086 | (...params: Parameters<Fn>): ReturnType<Fn>;
|
1087 |
|
1088 | and: SpyAnd<Fn>;
|
1089 | calls: Calls<Fn>;
|
1090 | withArgs(...args: MatchableArgs<Fn>): Spy<Fn>;
|
1091 | }
|
1092 |
|
1093 | type SpyObj<T> =
|
1094 | & T
|
1095 | & {
|
1096 | [K in keyof T]: T[K] extends Func ? T[K] & Spy<T[K]> : T[K];
|
1097 | };
|
1098 |
|
1099 | /**
|
1100 | * Determines whether the provided function is a Jasmine spy.
|
1101 | * @since 2.0.0
|
1102 | * @param putativeSpy The function to check.
|
1103 | */
|
1104 | function isSpy(putativeSpy: Func): putativeSpy is Spy;
|
1105 |
|
1106 | /**
|
1107 | * It's like SpyObj, but doesn't verify argument/return types for functions.
|
1108 | * Useful if TS cannot correctly infer type for complex objects.
|
1109 | */
|
1110 | type NonTypedSpyObj<T> = SpyObj<{ [K in keyof T]: T[K] extends Func ? Func : T[K] }>;
|
1111 |
|
1112 | /**
|
1113 | * Obtains the promised type that a promise-returning function resolves to.
|
1114 | */
|
1115 | type PromisedResolveType<T> = T extends PromiseLike<infer TResult> ? TResult : never;
|
1116 |
|
1117 | /**
|
1118 | * Obtains the type that a promise-returning function can be rejected with.
|
1119 | * This is so we can use .and.rejectWith() only for functions that return a promise.
|
1120 | */
|
1121 | type PromisedRejectType<T> = T extends PromiseLike<unknown> ? any : never;
|
1122 |
|
1123 | interface SpyAnd<Fn extends Func> {
|
1124 | identity: string;
|
1125 |
|
1126 | /** 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. */
|
1127 | callThrough(): Spy<Fn>;
|
1128 | /** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */
|
1129 | returnValue(val: ReturnType<Fn>): Spy<Fn>;
|
1130 | /** 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. */
|
1131 | returnValues(...values: Array<ReturnType<Fn>>): Spy<Fn>;
|
1132 | /** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */
|
1133 | callFake(fn: Fn): Spy<Fn>;
|
1134 | /** Tell the spy to return a promise resolving to the specified value when invoked. */
|
1135 | resolveTo(val?: PromisedResolveType<ReturnType<Fn>>): Spy<Fn>;
|
1136 | /** Tell the spy to return a promise rejecting with the specified value when invoked. */
|
1137 | rejectWith(val?: PromisedRejectType<ReturnType<Fn>>): Spy<Fn>;
|
1138 | /** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */
|
1139 | throwError(msg: string | Error): Spy;
|
1140 | /** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */
|
1141 | stub(): Spy;
|
1142 | }
|
1143 |
|
1144 | interface Calls<Fn extends Func> {
|
1145 | /** 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. */
|
1146 | any(): boolean;
|
1147 | /** By chaining the spy with calls.count(), will return the number of times the spy was called */
|
1148 | count(): number;
|
1149 | /** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index */
|
1150 | argsFor(index: number): Parameters<Fn>;
|
1151 | /** By chaining the spy with calls.allArgs(), will return the arguments to all calls */
|
1152 | allArgs(): ReadonlyArray<Parameters<Fn>>;
|
1153 | /** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls */
|
1154 | all(): ReadonlyArray<CallInfo<Fn>>;
|
1155 | /** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call */
|
1156 | mostRecent(): CallInfo<Fn>;
|
1157 | /** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call */
|
1158 | first(): CallInfo<Fn>;
|
1159 | /** By chaining the spy with calls.reset(), will clears all tracking for a spy */
|
1160 | reset(): void;
|
1161 | /** Set this spy to do a shallow clone of arguments passed to each invocation. */
|
1162 | saveArgumentsByValue(): void;
|
1163 | /** Get the "this" object that was passed to a specific invocation of this spy. */
|
1164 | thisFor(index: number): ThisType<Fn>;
|
1165 | }
|
1166 |
|
1167 | interface CallInfo<Fn extends Func> {
|
1168 | /** The context (the this) for the call */
|
1169 | object: ThisType<Fn>;
|
1170 | /** All arguments passed to the call */
|
1171 | args: Parameters<Fn>;
|
1172 | /** The return value of the call */
|
1173 | returnValue: ReturnType<Fn>;
|
1174 | }
|
1175 |
|
1176 | interface Util {
|
1177 | inherit(childClass: Function, parentClass: Function): any;
|
1178 | formatException(e: any): any;
|
1179 | htmlEscape(str: string): string;
|
1180 | argsToArray(args: any): any;
|
1181 | extend(destination: any, source: any): any;
|
1182 | }
|
1183 |
|
1184 | interface JsApiReporter extends CustomReporter {
|
1185 | new(): any;
|
1186 |
|
1187 | started: boolean;
|
1188 | finished: boolean;
|
1189 | runDetails: JasmineDoneInfo;
|
1190 |
|
1191 | status(): string;
|
1192 | suiteResults(index: number, length: number): SuiteResult[];
|
1193 | specResults(index: number, length: number): SpecResult[];
|
1194 | suites(): { [id: string]: SuiteResult };
|
1195 | specs(): SpecResult[];
|
1196 | executionTime(): number;
|
1197 | }
|
1198 |
|
1199 | interface Jasmine {
|
1200 | Spec: Spec;
|
1201 | clock: Clock;
|
1202 | util: Util;
|
1203 | }
|
1204 |
|
1205 | var HtmlReporter: HtmlReporter;
|
1206 | var HtmlSpecFilter: HtmlSpecFilter;
|
1207 |
|
1208 | /**
|
1209 | * Default number of milliseconds Jasmine will wait for an asynchronous spec to complete.
|
1210 | */
|
1211 | var DEFAULT_TIMEOUT_INTERVAL: number;
|
1212 |
|
1213 | /**
|
1214 | * Maximum number of array elements to display when pretty printing objects.
|
1215 | * This will also limit the number of keys and values displayed for an object.
|
1216 | * Elements past this number will be ellipised.
|
1217 | */
|
1218 | var MAX_PRETTY_PRINT_ARRAY_LENGTH: number;
|
1219 |
|
1220 | /**
|
1221 | * Maximum number of characters to display when pretty printing objects.
|
1222 | * Characters past this number will be ellipised.
|
1223 | */
|
1224 | var MAX_PRETTY_PRINT_CHARS: number;
|
1225 |
|
1226 | /**
|
1227 | * Maximum object depth the pretty printer will print to.
|
1228 | * Set this to a lower value to speed up pretty printing if you have large objects.
|
1229 | */
|
1230 | var MAX_PRETTY_PRINT_DEPTH: number;
|
1231 |
|
1232 | var version: string;
|
1233 |
|
1234 | interface JasmineOptions {
|
1235 | /**
|
1236 | * The path to the project's base directory. This can be absolute or relative
|
1237 | * to the current working directory. If it isn't specified, the current working
|
1238 | * directory will be used.
|
1239 | */
|
1240 | projectBaseDir?: string;
|
1241 | }
|
1242 |
|
1243 | interface JasmineConfig {
|
1244 | /**
|
1245 | * Whether to fail specs that contain no expectations.
|
1246 | * @default false
|
1247 | */
|
1248 | failSpecWithNoExpectations?: boolean;
|
1249 | /**
|
1250 | * An array of helper file paths or globs that match helper files. Each path or
|
1251 | * glob will be evaluated relative to the spec directory. Helpers are loaded before specs.
|
1252 | */
|
1253 | helpers?: string[];
|
1254 | /**
|
1255 | * Specifies how to load files with names ending in .js. Valid values are
|
1256 | * "require" and "import". "import" should be safe in all cases, and is
|
1257 | * required if your project contains ES modules with filenames ending in .js.
|
1258 | * @default "require"
|
1259 | */
|
1260 | jsLoader?: "require" | "import";
|
1261 | /**
|
1262 | * Whether to run specs in a random order.
|
1263 | */
|
1264 | random?: boolean;
|
1265 | /**
|
1266 | * An array of module names to load via require() at the start of execution.
|
1267 | */
|
1268 | requires?: string[];
|
1269 | /**
|
1270 | * The directory that spec files are contained in, relative to the project base directory.
|
1271 | */
|
1272 | spec_dir?: string;
|
1273 | /**
|
1274 | * An array of spec file paths or globs that match helper files. Each path
|
1275 | * or glob will be evaluated relative to the spec directory.
|
1276 | */
|
1277 | spec_files?: string[];
|
1278 | /**
|
1279 | * Whether to stop suite execution on the first spec failure.
|
1280 | */
|
1281 | stopOnSpecFailure?: boolean;
|
1282 | /**
|
1283 | * Whether to stop each spec on the first expectation failure.
|
1284 | */
|
1285 | stopSpecOnExpectationFailure?: boolean;
|
1286 | }
|
1287 |
|
1288 | interface DefaultReporterOptions {
|
1289 | timer?: any;
|
1290 | print?: (...args: any[]) => void;
|
1291 | showColors?: boolean;
|
1292 | jasmineCorePath?: string;
|
1293 | }
|
1294 | }
|
1295 |
|
1296 | declare module "jasmine" {
|
1297 | class jasmine {
|
1298 | jasmine: jasmine.Jasmine;
|
1299 | env: jasmine.Env;
|
1300 | /**
|
1301 | * @deprecated Private property that may be changed or removed in the future
|
1302 | */
|
1303 | reportersCount: number;
|
1304 | /**
|
1305 | * @deprecated Private property that may be changed or removed in the future
|
1306 | */
|
1307 | reporter: jasmine.CustomReporter;
|
1308 | /**
|
1309 | * @deprecated Private property that may be changed or removed in the future
|
1310 | */
|
1311 | showingColors: boolean;
|
1312 | /**
|
1313 | * @deprecated Private property that may be changed or removed in the future
|
1314 | */
|
1315 | projectBaseDir: string;
|
1316 | /**
|
1317 | * @deprecated Private property that may be changed or removed in the future
|
1318 | */
|
1319 | specDir: string;
|
1320 | /**
|
1321 | * @deprecated Private property that may be changed or removed in the future
|
1322 | */
|
1323 | specFiles: string[];
|
1324 | /**
|
1325 | * @deprecated Private property that may be changed or removed in the future
|
1326 | */
|
1327 | helperFiles: string[];
|
1328 | /**
|
1329 | * @deprecated Private property that may be changed or removed in the future
|
1330 | */
|
1331 | requires: string[];
|
1332 | /**
|
1333 | * @deprecated Private property that may be changed or removed in the future
|
1334 | */
|
1335 | defaultReporterConfigured: boolean;
|
1336 |
|
1337 | constructor(options?: jasmine.JasmineOptions);
|
1338 | addMatchers(matchers: jasmine.CustomMatcherFactories): void;
|
1339 | /**
|
1340 | * Add a custom reporter to the Jasmine environment.
|
1341 | */
|
1342 | addReporter(reporter: jasmine.CustomReporter): void;
|
1343 | /**
|
1344 | * Adds a spec file to the list that will be loaded when the suite is executed.
|
1345 | */
|
1346 | addSpecFile(filePath: string): void;
|
1347 | addMatchingSpecFiles(patterns: string[]): void;
|
1348 | addHelperFile(filePath: string): void;
|
1349 | addMatchingHelperFiles(patterns: string[]): void;
|
1350 | /**
|
1351 | * @deprecated Private method that may be changed or removed in the future
|
1352 | */
|
1353 | addRequires(files: string[]): void;
|
1354 | /**
|
1355 | * Configure the default reporter.
|
1356 | */
|
1357 | configureDefaultReporter(options: jasmine.DefaultReporterOptions): void;
|
1358 | execute(files?: string[], filterString?: string): Promise<jasmine.JasmineDoneInfo>;
|
1359 | exitOnCompletion: boolean;
|
1360 | loadConfig(config: jasmine.JasmineConfig): void;
|
1361 | loadConfigFile(configFilePath?: string): void;
|
1362 | /**
|
1363 | * @deprecated Private method that may be changed or removed in the future
|
1364 | */
|
1365 | loadHelpers(): Promise<void>;
|
1366 | /**
|
1367 | * @deprecated Private method that may be changed or removed in the future
|
1368 | */
|
1369 | loadSpecs(): Promise<void>;
|
1370 | /**
|
1371 | * @deprecated Private method that may be changed or removed in the future
|
1372 | */
|
1373 | loadRequires(): void;
|
1374 |
|
1375 | /**
|
1376 | * Provide a fallback reporter if no other reporters have been specified.
|
1377 | */
|
1378 | provideFallbackReporter(reporter: jasmine.CustomReporter): void;
|
1379 | /**
|
1380 | * Clears all registered reporters.
|
1381 | */
|
1382 | clearReporters(): void;
|
1383 | /**
|
1384 | * Sets whether to randomize the order of specs.
|
1385 | */
|
1386 | randomizeTests(value: boolean): void;
|
1387 | /**
|
1388 | * Sets the random seed.
|
1389 | */
|
1390 | seed(value: number): void;
|
1391 | /**
|
1392 | * Sets whether to show colors in the console reporter.
|
1393 | */
|
1394 | showColors(value: boolean): void;
|
1395 | stopSpecOnExpectationFailure(value: boolean): void;
|
1396 | stopOnSpecFailure(value: boolean): void;
|
1397 | static ConsoleReporter(): any;
|
1398 |
|
1399 | /**
|
1400 | * The version of jasmine-core in use
|
1401 | */
|
1402 | coreVersion(): string;
|
1403 | }
|
1404 | export = jasmine;
|
1405 | }
|