Members
(static) DEFAULT_TIMEOUT_INTERVAL
Default number of milliseconds Jasmine will wait for an asynchronous spec,
before, or after function to complete. This can be overridden on a case by
case basis by passing a time limit as the third argument to it
,
beforeEach
, afterEach
, beforeAll
, or
afterAll
. The value must be no greater than the largest number of
milliseconds supported by setTimeout, which is usually 2147483647.
While debugging tests, you may want to set this to a large number (or pass a large number to one of the functions mentioned above) so that Jasmine does not move on to after functions or the next spec while you're debugging.
- Since:
- 1.3.0
- Default Value:
- 5000
(static) MAX_PRETTY_PRINT_ARRAY_LENGTH
Maximum number of array elements to display when pretty printing objects. This will also limit the number of keys and values displayed for an object. Elements past this number will be ellipised.
- Since:
- 2.7.0
- Default Value:
- 50
(static) MAX_PRETTY_PRINT_CHARS
Maximum number of characters to display when pretty printing objects. Characters past this number will be ellipised.
- Since:
- 2.9.0
- Default Value:
- 100
(static) MAX_PRETTY_PRINT_DEPTH
Maximum object depth the pretty printer will print to. Set this to a lower value to speed up pretty printing if you have large objects.
- Since:
- 1.3.0
- Default Value:
- 8
Methods
(static) addAsyncMatchers(matchers)
Add custom async matchers for the current scope of specs.
Note: This is only callable from within a beforeEach
, it
, or beforeAll
.
Parameters:
Name | Type | Description |
---|---|---|
matchers |
Object | Keys from this object will be the new async matcher names. |
- Since:
- 3.5.0
- See:
(static) addCustomEqualityTester(tester)
Add a custom equality tester for the current scope of specs.
Note: This is only callable from within a beforeEach
, it
, or beforeAll
.
Parameters:
Name | Type | Description |
---|---|---|
tester |
function | A function which takes two arguments to compare and returns a |
- Since:
- 2.0.0
- See:
(static) addCustomObjectFormatter(formatter)
Add a custom object formatter for the current scope of specs.
Note: This is only callable from within a beforeEach
, it
, or beforeAll
.
Parameters:
Name | Type | Description |
---|---|---|
formatter |
function | A function which takes a value to format and returns a string if it knows how to format it, and |
- Since:
- 3.6.0
- See:
(static) addMatchers(matchers)
Add custom matchers for the current scope of specs.
Note: This is only callable from within a beforeEach
, it
, or beforeAll
.
Parameters:
Name | Type | Description |
---|---|---|
matchers |
Object | Keys from this object will be the new matcher names. |
- Since:
- 2.0.0
- See:
(static) addSpyStrategy(name, factory)
Add a custom spy strategy for the current scope of specs.
Note: This is only callable from within a beforeEach
, it
, or beforeAll
.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | The name of the strategy (i.e. what you call from |
factory |
function | Factory function that returns the plan to be executed. |
- Since:
- 3.5.0
(static) any(clazz)
Get an AsymmetricEqualityTester
, usable in any matcher
that uses Jasmine's equality (e.g. toEqual
, toContain
, or toHaveBeenCalledWith
),
that will succeed if the actual value being compared is an instance of the specified class/constructor.
Parameters:
Name | Type | Description |
---|---|---|
clazz |
Constructor | The constructor to check against. |
- Since:
- 1.3.0
(static) anything()
Get an AsymmetricEqualityTester
, usable in any matcher
that uses Jasmine's equality (e.g. toEqual
, toContain
, or toHaveBeenCalledWith
),
that will succeed if the actual value being compared is not null
and not undefined
.
- Since:
- 2.2.0
(static) arrayContaining(sample)
Get an AsymmetricEqualityTester
, usable in any matcher
that uses Jasmine's equality (e.g. toEqual
, toContain
, or toHaveBeenCalledWith
),
that will succeed if the actual value is an Array
that contains at least the elements in the sample.
Parameters:
Name | Type | Description |
---|---|---|
sample |
Array |
- Since:
- 2.2.0
(static) arrayWithExactContents(sample)
Get an AsymmetricEqualityTester
, usable in any matcher
that uses Jasmine's equality (e.g. toEqual
, toContain
, or toHaveBeenCalledWith
),
that will succeed if the actual value is an Array
that contains all of the elements in the sample in any order.
Parameters:
Name | Type | Description |
---|---|---|
sample |
Array |
- Since:
- 2.8.0
(static) clock() → {Clock}
Get the currently booted mock {Clock} for this Jasmine environment.
- Since:
- 2.0.0
Returns:
- Type
- Clock
(static) createSpy(nameopt, originalFnopt) → {Spy}
Create a bare Spy
object. This won't be installed anywhere and will not have any implementation behind it.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
String |
<optional> |
Name to give the spy. This will be displayed in failure messages. |
originalFn |
function |
<optional> |
Function to act as the real implementation. |
- Since:
- 1.3.0
Returns:
- Type
- Spy
(static) createSpyObj(baseNameopt, methodNames, propertyNamesopt) → {Object}
Create an object with multiple Spy
s as its members.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
baseName |
String |
<optional> |
Base name for the spies in the object. |
methodNames |
Array.<String> | Object | Array of method names to create spies for, or Object whose keys will be method names and values the |
|
propertyNames |
Array.<String> | Object |
<optional> |
Array of property names to create spies for, or Object whose keys will be propertynames and values the |
- Since:
- 1.3.0
Returns:
- Type
- Object
(static) empty()
Get an AsymmetricEqualityTester
, usable in any matcher
that uses Jasmine's equality (e.g. toEqual
, toContain
, or toHaveBeenCalledWith
),
that will succeed if the actual value being compared is empty.
- Since:
- 3.1.0
(static) falsy()
Get an AsymmetricEqualityTester
, usable in any matcher
that uses Jasmine's equality (e.g. toEqual
, toContain
, or toHaveBeenCalledWith
),
that will succeed if the actual value being compared is null
, undefined
, 0
, false
or anything falsey.
- Since:
- 3.1.0
(static) getEnv() → {Env}
Get the currently booted Jasmine Environment.
- Since:
- 1.3.0
Returns:
- Type
- Env
(static) isSpy(putativeSpy) → {Boolean}
Determines whether the provided function is a Jasmine spy.
Parameters:
Name | Type | Description |
---|---|---|
putativeSpy |
function | The function to check. |
- Since:
- 2.0.0
Returns:
- Type
- Boolean
(static) mapContaining(sample)
Get an AsymmetricEqualityTester
, usable in any matcher
that uses Jasmine's equality (e.g. toEqual
, toContain
, or toHaveBeenCalledWith
),
that will succeed if every key/value pair in the sample passes the deep equality comparison
with at least one key/value pair in the actual value being compared
Parameters:
Name | Type | Description |
---|---|---|
sample |
Map | The subset of items that must be in the actual. |
- Since:
- 3.5.0
(static) notEmpty()
Get an AsymmetricEqualityTester
, usable in any matcher
that uses Jasmine's equality (e.g. toEqual
, toContain
, or toHaveBeenCalledWith
),
that will succeed if the actual value being compared is not empty.
- Since:
- 3.1.0
(static) objectContaining(sample)
Get an AsymmetricEqualityTester
, usable in any matcher
that uses Jasmine's equality (e.g. toEqual
, toContain
, or toHaveBeenCalledWith
),
that will succeed if the actual value being compared contains at least the keys and values.
Parameters:
Name | Type | Description |
---|---|---|
sample |
Object | The subset of properties that must be in the actual. |
- Since:
- 1.3.0
(static) setContaining(sample)
Get an AsymmetricEqualityTester
, usable in any matcher
that uses Jasmine's equality (e.g. toEqual
, toContain
, or toHaveBeenCalledWith
),
that will succeed if every item in the sample passes the deep equality comparison
with at least one item in the actual value being compared
Parameters:
Name | Type | Description |
---|---|---|
sample |
Set | The subset of items that must be in the actual. |
- Since:
- 3.5.0
(static) setDefaultSpyStrategy(defaultStrategyFn)
Set the default spy strategy for the current scope of specs.
Note: This is only callable from within a beforeEach
, it
, or beforeAll
.
Parameters:
Name | Type | Description |
---|---|---|
defaultStrategyFn |
function | a function that assigns a strategy |
Example
beforeEach(function() {
jasmine.setDefaultSpyStrategy(and => and.returnValue(true));
});
(static) stringContaining(expected)
Get an AsymmetricEqualityTester
, usable in any matcher
that uses Jasmine's equality (e.g. toEqual
, toContain
, or toHaveBeenCalledWith
),
that will succeed if the actual value is a String
that contains the specified String
.
Parameters:
Name | Type | Description |
---|---|---|
expected |
String |
- Since:
- 3.10.0
(static) stringMatching(expected)
Get an AsymmetricEqualityTester
, usable in any matcher
that uses Jasmine's equality (e.g. toEqual
, toContain
, or toHaveBeenCalledWith
),
that will succeed if the actual value is a String
that matches the RegExp
or String
.
Parameters:
Name | Type | Description |
---|---|---|
expected |
RegExp | String |
- Since:
- 2.2.0
(static) truthy()
Get an AsymmetricEqualityTester
, usable in any matcher
that uses Jasmine's equality (e.g. toEqual
, toContain
, or toHaveBeenCalledWith
),
that will succeed if the actual value being compared is true
or anything truthy.
- Since:
- 3.1.0