@@ -359,6 +359,12 @@ declare namespace jasmine {
359359 /** @deprecated Please use `Configuration` instead of `EnvConfiguration`. */
360360 type EnvConfiguration = Configuration ;
361361
362+ /**
363+ * Get the currently booted mock {Clock} for this Jasmine environment.
364+ * @name jasmine.clock
365+ * @since 2.0.0
366+ * @returns {Clock }
367+ */
362368 function clock ( ) : Clock ;
363369 /**
364370 * @deprecated Private method that may be changed or removed in the future
@@ -408,28 +414,189 @@ declare namespace jasmine {
408414 */
409415 function is ( sample : any ) : AsymmetricMatcher < any > ;
410416
417+ /**
418+ * Get an {@link AsymmetricEqualityTester} that will succeed if the actual
419+ * value is an `Array` that contains at least the elements in the sample.
420+ * @since 2.2.0
421+ * @param sample
422+ */
411423 function arrayContaining < T > ( sample : ArrayLike < T > ) : ArrayContaining < T > ;
424+ /**
425+ * Get an {@link AsymmetricEqualityTester} that will succeed if the actual
426+ * value is an `Array` that contains all of the elements in the sample in
427+ * any order.
428+ * @since 2.8.0
429+ * @param sample
430+ */
412431 function arrayWithExactContents < T > ( sample : ArrayLike < T > ) : ArrayContaining < T > ;
432+
433+ /**
434+ * Get an {@link AsymmetricEqualityTester} that will succeed if the actual
435+ * value being compared contains at least the specified keys and values.
436+ * @since 1.3.0
437+ * @param sample - The subset of properties that _must_ be in the actual.
438+ */
413439 function objectContaining < T > ( sample : { [ K in keyof T ] ?: ExpectedRecursive < T [ K ] > } ) : ObjectContaining < T > ;
440+ /**
441+ * Get an {@link AsymmetricEqualityTester} that will succeed if every
442+ * key/value pair in the sample passes the deep equality comparison
443+ * with at least one key/value pair in the actual value being compared
444+ * @since 3.5.0
445+ * @param sample - The subset of items that _must_ be in the actual.
446+ */
414447 function mapContaining < K , V > ( sample : Map < K , V > ) : AsymmetricMatcher < Map < K , V > > ;
448+ /**
449+ * Get an {@link AsymmetricEqualityTester} that will succeed if every item
450+ * in the sample passes the deep equality comparison
451+ * with at least one item in the actual value being compared
452+ * @since 3.5.0
453+ * @param sample - The subset of items that _must_ be in the actual.
454+ */
415455 function setContaining < T > ( sample : Set < T > ) : AsymmetricMatcher < Set < T > > ;
416456
457+ /**
458+ * Set the default spy strategy for the current scope of specs.
459+ *
460+ * _Note:_ This is only callable from within a {@link beforeEach}, {@link it}, or {@link beforeAll}.
461+ * @param defaultStrategyFn - a function that assigns a strategy
462+ * @example
463+ * beforeEach(function() {
464+ * jasmine.setDefaultSpyStrategy(and => and.returnValue(true));
465+ * });
466+ */
417467 function setDefaultSpyStrategy < Fn extends Func = Func > ( fn ?: ( and : SpyAnd < Fn > ) => void ) : void ;
468+
469+ /**
470+ * Replaces Jasmine's global error handling with a spy. This prevents Jasmine
471+ * from treating uncaught exceptions and unhandled promise rejections
472+ * as spec failures and allows them to be inspected using the spy's
473+ * {@link Spy#calls|calls property} and related matchers such as
474+ * {@link matchers#toHaveBeenCalledWith|toHaveBeenCalledWith}.
475+ *
476+ * After installing the spy, spyOnGlobalErrorsAsync immediately calls its
477+ * argument, which must be an async or promise-returning function. The spy
478+ * will be passed as the first argument to that callback. Normal error
479+ * handling will be restored when the promise returned from the callback is
480+ * settled.
481+ *
482+ * When the JavaScript runtime reports an uncaught error or unhandled rejection,
483+ * the spy will be called with a single parameter representing Jasmine's best
484+ * effort at describing the error. This parameter may be of any type, because
485+ * JavaScript allows anything to be thrown or used as the reason for a
486+ * rejected promise, but Error instances and strings are most common.
487+ *
488+ * Note: The JavaScript runtime may deliver uncaught error events and unhandled
489+ * rejection events asynchronously, especially in browsers. If the event
490+ * occurs after the promise returned from the callback is settled, it won't
491+ * be routed to the spy even if the underlying error occurred previously.
492+ * It's up to you to ensure that all of the error/rejection events that you
493+ * want to handle have occurred before you resolve the promise returned from
494+ * the callback.
495+ *
496+ * You must ensure that the `it`/`beforeEach`/etc fn that called
497+ * `spyOnGlobalErrorsAsync` does not signal completion until after the
498+ * promise returned by `spyOnGlobalErrorsAsync` is resolved. Normally this is
499+ * done by `await`ing the returned promise. Leaving the global error spy
500+ * installed after the `it`/`beforeEach`/etc fn that installed it signals
501+ * completion is likely to cause problems and is not supported.
502+ * @param fn - A function to run, during which the global error spy will be effective
503+ * @example
504+ * it('demonstrates global error spies', async function() {
505+ * await jasmine.spyOnGlobalErrorsAsync(async function(globalErrorSpy) {
506+ * setTimeout(function() {
507+ * throw new Error('the expected error');
508+ * });
509+ * await new Promise(function(resolve) {
510+ * setTimeout(resolve);
511+ * });
512+ * const expected = new Error('the expected error');
513+ * expect(globalErrorSpy).toHaveBeenCalledWith(expected);
514+ * });
515+ * });
516+ */
418517 function spyOnGlobalErrorsAsync ( fn ?: ( globalErrorSpy : Spy < ( error : Error ) => void > ) => Promise < void > ) : Promise < void > ;
518+ /**
519+ * Add a custom spy strategy for the current scope of specs.
520+ *
521+ * _Note:_ This is only callable from within a {@link beforeEach}, {@link it}, or {@link beforeAll}.
522+ * @since 3.5.0
523+ * @param name - The name of the strategy (i.e. what you call from `and`)
524+ * @param factory - Factory function that returns the plan to be executed.
525+ */
419526 function addSpyStrategy < Fn extends Func = Func > ( name : string , factory : Fn ) : void ;
527+ /**
528+ * Create a bare {@link Spy} object. This won't be installed anywhere and will not have any implementation behind it.
529+ * @since 1.3.0
530+ * @param name - Name to give the spy. This will be displayed in failure messages.
531+ * @param originalFn - The "real" function. This will
532+ * be used for subsequent calls to the spy after you call
533+ * `mySpy.and.callThrough()`. In most cases you should omit this parameter.
534+ * The usual way to supply an original function is to call {@link spyOn}
535+ * instead of createSpy.
536+ */
420537 function createSpy < Fn extends Func > ( name ?: string , originalFn ?: Fn ) : Spy < Fn > ;
538+ /**
539+ * Create an object with multiple {@link Spy}s as its members.
540+ * @since 1.3.0
541+ * @param baseName - Base name for the spies in the object.
542+ * @param methodNames - Array of method names to create spies for, or Object whose keys will be method names and values the {@link Spy#and#returnValue|returnValue}.
543+ * @param propertyNames - Array of property names to create spies for, or Object whose keys will be propertynames and values the {@link Spy#and#returnValue|returnValue}.
544+ */
421545 function createSpyObj ( baseName : string , methodNames : SpyObjMethodNames , propertyNames ?: SpyObjPropertyNames ) : any ;
546+ /**
547+ * Create an object with multiple {@link Spy}s as its members.
548+ * @since 1.3.0
549+ * @param baseName - Base name for the spies in the object.
550+ * @param methodNames - Array of method names to create spies for, or Object whose keys will be method names and values the {@link Spy#and#returnValue|returnValue}.
551+ * @param propertyNames - Array of property names to create spies for, or Object whose keys will be propertynames and values the {@link Spy#and#returnValue|returnValue}.
552+ */
422553 function createSpyObj < T > (
423554 baseName : string ,
424555 methodNames : SpyObjMethodNames < T > ,
425556 propertyNames ?: SpyObjPropertyNames < T > ,
426557 ) : SpyObj < T > ;
558+ /**
559+ * Create an object with multiple {@link Spy}s as its members.
560+ * @since 1.3.0
561+ * @param baseName - Base name for the spies in the object.
562+ * @param methodNames - Array of method names to create spies for, or Object whose keys will be method names and values the {@link Spy#and#returnValue|returnValue}.
563+ * @param propertyNames - Array of property names to create spies for, or Object whose keys will be propertynames and values the {@link Spy#and#returnValue|returnValue}.
564+ */
427565 function createSpyObj ( methodNames : SpyObjMethodNames , propertyNames ?: SpyObjPropertyNames ) : any ;
566+ /**
567+ * Create an object with multiple {@link Spy}s as its members.
568+ * @since 1.3.0
569+ * @param baseName - Base name for the spies in the object.
570+ * @param methodNames - Array of method names to create spies for, or Object whose keys will be method names and values the {@link Spy#and#returnValue|returnValue}.
571+ * @param propertyNames - Array of property names to create spies for, or Object whose keys will be propertynames and values the {@link Spy#and#returnValue|returnValue}.
572+ */
428573 function createSpyObj < T > ( methodNames : SpyObjMethodNames < T > , propertyNames ?: SpyObjPropertyNames < T > ) : SpyObj < T > ;
429574
575+ /**
576+ * Get the currently booted Jasmine Environment.
577+ *
578+ * @since 1.3.0
579+ */
430580 function getEnv ( ) : Env ;
581+ /**
582+ * Logs a message for use in debugging. If the spec fails, trace messages
583+ * will be included in the {@link SpecDoneEvent|result} passed to the
584+ * reporter's specDone method.
585+ *
586+ * This method should be called only when a spec (including any associated
587+ * beforeEach or afterEach functions) is running.
588+ * @since 4.0.0
589+ * @param msg - The message to log
590+ */
431591 function debugLog ( msg : string ) : void ;
432592
593+ /**
594+ * Add a custom equality tester for the current scope of specs.
595+ *
596+ * _Note:_ This is only callable from within a {@link beforeEach}, {@link it}, or {@link beforeAll}.
597+ * @since 2.0.0
598+ * @param tester - A function which takes two arguments to compare and returns a `true` or `false` comparison result if it knows how to compare them, and `undefined` otherwise.
599+ */
433600 function addCustomEqualityTester ( equalityTester : CustomEqualityTester ) : void ;
434601
435602 /**
@@ -440,16 +607,38 @@ declare namespace jasmine {
440607 */
441608 function addCustomObjectFormatter ( formatter : CustomObjectFormatter ) : void ;
442609
610+ /**
611+ * Add custom matchers for the current scope of specs.
612+ *
613+ * _Note:_ This is only callable from within a {@link beforeEach}, {@link it}, or {@link beforeAll}.
614+ * @since 2.0.0
615+ * @param matchers - Keys from this object will be the new matcher names.
616+ */
443617 function addMatchers ( matchers : CustomMatcherFactories ) : void ;
618+ /**
619+ * Add custom async matchers for the current scope of specs.
620+ *
621+ * _Note:_ This is only callable from within a {@link beforeEach}, {@link it}, or {@link beforeAll}.
622+ * @since 3.5.0
623+ * @param matchers - Keys from this object will be the new async matcher names.
624+ */
444625 function addAsyncMatchers ( matchers : CustomAsyncMatcherFactories ) : void ;
445626
446- function stringMatching ( str : string | RegExp ) : AsymmetricMatcher < string > ;
627+ /**
628+ * Get an {@link AsymmetricEqualityTester} that will succeed if the actual
629+ * value is a `String` that matches the `RegExp` or `String`.
630+ * @since 2.2.0
631+ * @param expected
632+ */
633+ function stringMatching ( expected : string | RegExp ) : AsymmetricMatcher < string > ;
447634
448- function stringContaining ( str : string ) : AsymmetricMatcher < string > ;
449635 /**
450- * @deprecated Private method that may be changed or removed in the future
636+ * Get an {@link AsymmetricEqualityTester} that will succeed if the actual
637+ * value is a `String` that contains the specified `String`.
638+ * @since 3.10.0
639+ * @param expected
451640 */
452- function formatErrorMsg ( domain : string , usage : string ) : ( msg : string ) => string ;
641+ function stringContaining ( expected : string ) : AsymmetricMatcher < string > ;
453642
454643 interface Any extends AsymmetricMatcher < any > {
455644 new ( expectedClass : any ) : any ;
@@ -558,6 +747,14 @@ declare namespace jasmine {
558747
559748 interface Env {
560749 addReporter ( reporter : CustomReporter ) : void ;
750+ /**
751+ * Configures whether Jasmine should allow the same function to be spied on
752+ * more than once during the execution of a spec. By default, spying on
753+ * a function that is already a spy will cause an error.
754+ * @name Env#allowRespy
755+ * @since 2.5.0
756+ * @param allow Whether to allow respying
757+ */
561758 allowRespy ( allow : boolean ) : void ;
562759 clearReporters ( ) : void ;
563760 configuration ( ) : Configuration ;
@@ -576,6 +773,12 @@ declare namespace jasmine {
576773 * @since 3.6.0
577774 */
578775 setSuiteProperty : typeof setSuiteProperty ;
776+ /**
777+ * Provides the root suite, through which all suites and specs can be
778+ * accessed.
779+ * @return the root suite
780+ * @since 2.0.0
781+ */
579782 topSuite ( ) : Suite ;
580783 }
581784
@@ -682,25 +885,57 @@ declare namespace jasmine {
682885 // tslint:disable-next-line unified-signatures
683886 toMatch ( expected : string | RegExp , expectationFailOutput : any ) : void ;
684887
888+ /**
889+ * {@link expect } the actual value to be defined. (Not `undefined`)
890+ * @name matchers#toBeDefined
891+ * @since 1.3.0
892+ * @example
893+ * expect(result).toBeDefined();
894+ */
685895 toBeDefined ( ) : void ;
686896 /**
687897 * @deprecated expectationFailOutput is deprecated. Use withContext instead.
688898 */
689899 // tslint:disable-next-line unified-signatures
690900 toBeDefined ( expectationFailOutput : any ) : void ;
901+ /**
902+ * {@link expect } the actual value to be `undefined`.
903+ * @since 1.3.0
904+ * @example
905+ * expect(result).toBeUndefined():
906+ */
691907 toBeUndefined ( ) : void ;
692908 /**
693909 * @deprecated expectationFailOutput is deprecated. Use withContext instead.
694910 */
695911 // tslint:disable-next-line unified-signatures
696912 toBeUndefined ( expectationFailOutput : any ) : void ;
913+ /**
914+ * {@link expect } the actual value to be `null`.
915+ * @since 1.3.0
916+ * @example
917+ * expect(result).toBeNull();
918+ */
697919 toBeNull ( ) : void ;
698920 /**
699921 * @deprecated expectationFailOutput is deprecated. Use withContext instead.
700922 */
701923 // tslint:disable-next-line unified-signatures
702924 toBeNull ( expectationFailOutput : any ) : void ;
925+ /**
926+ * {@link expect } the actual value to be `NaN` (Not a Number).
927+ * @since 1.3.0
928+ * @example
929+ * expect(thing).toBeNaN();
930+ */
703931 toBeNaN ( ) : void ;
932+
933+ /**
934+ * {@link expect } the actual value to be truthy.
935+ * @since 2.0.0
936+ * @example
937+ * expect(thing).toBeTruthy();
938+ */
704939 toBeTruthy ( ) : void ;
705940 /**
706941 * @deprecated expectationFailOutput is deprecated. Use withContext instead.
@@ -715,10 +950,45 @@ declare namespace jasmine {
715950 toBeFalsy ( expectationFailOutput : any ) : void ;
716951 toBeTrue ( ) : void ;
717952 toBeFalse ( ) : void ;
953+ /**
954+ * {@link expect } the actual (a {@link Spy}) to have been called.
955+ * @since 1.3.0
956+ * @example
957+ * expect(mySpy).toHaveBeenCalled();
958+ * expect(mySpy).not.toHaveBeenCalled();
959+ */
718960 toHaveBeenCalled ( ) : void ;
961+ /**
962+ * {@link expect } the actual value (a {@link Spy}) to have been called before another {@link Spy}.
963+ * @since 2.6.0
964+ * @param expected - {@link Spy} that should have been called after the `actual` {@link Spy}.
965+ * @example
966+ * expect(mySpy).toHaveBeenCalledBefore(otherSpy);
967+ */
719968 toHaveBeenCalledBefore ( expected : Func ) : void ;
969+ /**
970+ * {@link expect } the actual (a {@link Spy}) to have been called with particular arguments at least once.
971+ * @since 1.3.0
972+ * @param params - The arguments to look for
973+ * @example
974+ * expect(mySpy).toHaveBeenCalledWith('foo', 'bar', 2);
975+ */
720976 toHaveBeenCalledWith ( ...params : any [ ] ) : void ;
977+ /**
978+ * {@link expect } the actual (a {@link Spy}) to have been called exactly once, and exactly with the particular arguments.
979+ * @since 3.6.0
980+ * @param params - The arguments to look for
981+ * @example
982+ * expect(mySpy).toHaveBeenCalledOnceWith('foo', 'bar', 2);
983+ */
721984 toHaveBeenCalledOnceWith ( ...params : any [ ] ) : void ;
985+ /**
986+ * {@link expect } the actual (a {@link Spy}) to have been called the specified number of times.
987+ * @since 2.4.0
988+ * @param expected - The number of invocations to look for.
989+ * @example
990+ * expect(mySpy).toHaveBeenCalledTimes(3);
991+ */
722992 toHaveBeenCalledTimes ( expected : number ) : void ;
723993 toContain ( expected : any ) : void ;
724994 /**
0 commit comments