#

API Docs for: 3.10.3
Show: Inherited Protected Private Deprecated

# Test.Mock Class

Defined in: `test/js/Mock.js:1`
Module: test

Creates a new mock object.

- Index
- Methods

## Item Index

### Methods

- expect static
- verify static

## Methods

### `expect`

(

- `mock`
- `expectation`

)
Void static

Defined in `test/js/Mock.js:45`

Assigns an expectation to a mock object. This is used to create methods and properties on the mock object that are monitored for calls and changes, respectively.

#### Parameters:

- `mock` Object

  The object to add the expectation to.

- `expectation` Object

  An object defining the expectation. For properties, the keys "property" and "value" are required. For a method the "method" key defines the method's name, the optional "args" key provides an array of argument types. The "returns" key provides an optional return value. An optional "run" key provides a function to be used as the method body. The return value of a mocked method is determined first by the "returns" key, then the "run" function's return value. If neither "returns" nor "run" is provided undefined is returned. An optional 'error' key defines an error type to be thrown in all cases. The "callCount" key provides an optional number of times the method is expected to be called (the default is 1).

#### Returns:

Void:

### `verify`

(

- `mock`

)
Void static

Defined in `test/js/Mock.js:137`

Verifies that all expectations of a mock object have been met and throws an assertion error if not.

#### Parameters:

- `mock` Object

  The object to verify..

#### Returns:

Void: