Members
(static) DEFAULT_TIMEOUT_INTERVAL
Default number of milliseconds Jasmine will wait for an asynchronous spec to complete.
- Since:
- 1.3.0
(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
(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
(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
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 a matcher, 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 a matcher, 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 a matcher, 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 a matcher, 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 a matcher, 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 a matcher, 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) mapContaining(sample)
Get a matcher, 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 a matcher, 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 a matcher, 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 a matcher, 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) stringMatching(expected)
Get a matcher, 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 a matcher, 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