Global

Methods

afterEach(afterEachFunction)

A function that is called after each spec in a suite. Used for restoring any state that is hijacked during spec execution.
Parameters:
Name Type Description
afterEachFunction function

afterOnce(afterOnceFunction)

A function that is called once after all specs in a suite. Used for restoring any state that is hijacked during suite execution. Will not be executed when there is no spec in the current suite—or if all spec have been skipped.
Parameters:
Name Type Description
afterOnceFunction function

beforeEach(beforeEachFunction)

A function that is called before each spec in a suite. Used for spec setup, including validating assumptions.
Parameters:
Name Type Description
beforeEachFunction function

beforeOnce(beforeOnceFunction)

A function that is called once before any spec in a suite. Used for suite setup, including validating assumptions. Will not be executed when there is no spec in the current suite—or if all spec have been skipped.
Parameters:
Name Type Description
beforeOnceFunction function

describe(description, specDefinitions) → {jasmine.Suite}

Defines a suite of specifications. Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization of setup in some tests.
Parameters:
Name Type Description
description String A string, usually the class under test.
specDefinitions function function that defines several specs.
Returns:
Type
jasmine.Suite
Example
describe("suite description", function() {
    it("spec description", function() {
        expect(true).toBeTruthy();
    });
    describe("subsuite description, function() {
        // ...
    });
});

describeDb(description, specDefinitions)

Defines a suite of specifications. Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization of setup in some tests. Opens a database connection for each spec (before the first beforeEach). This connection is rolled back and closed automatically by the framework (after the last afterEach). The connection is accessible by
this.dbConnection
.
Parameters:
Name Type Description
description String A string, usually the class under test.
specDefinitions function function that defines several specs.
Deprecated:

expect(actual) → {jasmine.Expectation}

Starts a chain for a Jasmine expectation. It is passed an Object that is the actual value and should chain to one of the many jasmine.Matchers functions.
Parameters:
Name Type Description
actual Object Actual value to test against and expected value
Returns:
Type
jasmine.Expectation

it(desc, func) → {jasmine.Spec}

Creates a Jasmine spec that will be added to the current suite.
Parameters:
Name Type Description
desc String description of this specification
func function defines the preconditions and expectations of the spec
Returns:
Type
jasmine.Spec
Example
it('should be true', function() {
    expect(true).toEqual(true);
});

spyOn(obj, methodName) → {jasmine.Spy}

Function that installs a spy on an existing object's method name. Used within a Spec to create a spy.
Parameters:
Name Type Description
obj
methodName
Returns:
a Jasmine spy that can be chained with all spy methods
Type
jasmine.Spy
Example
// spy example
var foo = {
    not : function(bool) {
        return !bool;
    }
};
spyOn(foo, 'not');
// actual foo.not will not be called, execution stops

xdescribe(description, specDefinitions) → {jasmine.Suite}

Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
Parameters:
Name Type Description
description String A string, usually the class under test.
specDefinitions function function that defines several specs.
Returns:
Type
jasmine.Suite

xdescribeDb(description, specDefinitions)

Defines a suite of specifications that is skipped during execution. Used to disable some suites in a file, or files, temporarily during development.
Parameters:
Name Type Description
description String A string, usually the class under test.
specDefinitions function function that defines several specs.
Deprecated:

xit(desc, func) → {jasmine.Spec}

Creates a pending Jasmine spec. A convenience method that allows existing specs to be disabled temporarily during development.
Parameters:
Name Type Description
desc String description of this specification
func function defines the preconditions and expectations of the spec
Returns:
Type
jasmine.Spec