W3cubDocs

/Jasmine

Global

Methods

afterAll(functionopt, timeoutopt)

Run some shared teardown once before all of the specs in the describe are run.

Note: Be careful, sharing the teardown from a afterAll makes it easy to accidentally leak state between your specs so that they erroneously pass or fail.

Parameters:
Name Type Attributes Default Description
function function <optional>

Function that contains the code to teardown your specs.

timeout Int <optional>
jasmine.DEFAULT_TIMEOUT_INTERVAL

Custom timeout for an async afterAll.

afterEach(functionopt, timeoutopt)

Run some shared teardown after each of the specs in the describe in which it is called.

Parameters:
Name Type Attributes Default Description
function function <optional>

Function that contains the code to teardown your specs.

timeout Int <optional>
jasmine.DEFAULT_TIMEOUT_INTERVAL

Custom timeout for an async afterEach.

beforeAll(functionopt, timeoutopt)

Run some shared setup once before all of the specs in the describe are run.

Note: Be careful, sharing the setup from a beforeAll makes it easy to accidentally leak state between your specs so that they erroneously pass or fail.

Parameters:
Name Type Attributes Default Description
function function <optional>

Function that contains the code to setup your specs.

timeout Int <optional>
jasmine.DEFAULT_TIMEOUT_INTERVAL

Custom timeout for an async beforeAll.

beforeEach(functionopt, timeoutopt)

Run some shared setup before each of the specs in the describe in which it is called.

Parameters:
Name Type Attributes Default Description
function function <optional>

Function that contains the code to setup your specs.

timeout Int <optional>
jasmine.DEFAULT_TIMEOUT_INTERVAL

Custom timeout for an async beforeEach.

describe(description, specDefinitions)

Create a group of specs (often called a suite).

Calls to describe can be nested within other calls to compose your suite as a tree.

Parameters:
Name Type Description
description String

Textual description of the group

specDefinitions function

Function for Jasmine to invoke that will define inner suites a specs

expect(actual) → {matchers}

Create an expectation for a spec.

Parameters:
Name Type Description
actual Object

Actual computed value to test expectations against.

Returns:
Type
matchers

fail(erroropt)

Explicitly mark a spec as failed.

Parameters:
Name Type Attributes Description
error String | Error <optional>

Reason for the failure.

fdescribe(description, specDefinitions)

A focused describe

If suites or specs are focused, only those that are focused will be executed

Parameters:
Name Type Description
description String

Textual description of the group

specDefinitions function

Function for Jasmine to invoke that will define inner suites a specs

See:

fit(description, testFunction, timeoutopt)

A focused it

If suites or specs are focused, only those that are focused will be executed.

Parameters:
Name Type Attributes Default Description
description String

Textual description of what this spec is checking.

testFunction function

Function that contains the code of your test.

timeout Int <optional>
jasmine.DEFAULT_TIMEOUT_INTERVAL

Custom timeout for an async spec.

it(description, testFunctionopt, timeoutopt)

Define a single spec. A spec should contain one or more expectations that test the state of the code.

A spec whose expectations all succeed will be passing and a spec with any failures will fail.

Parameters:
Name Type Attributes Default Description
description String

Textual description of what this spec is checking

testFunction function <optional>

Function that contains the code of your test. If not provided the test will be pending.

timeout Int <optional>
jasmine.DEFAULT_TIMEOUT_INTERVAL

Custom timeout for an async spec.

pending(messageopt)

Mark a spec as pending, expectation results will be ignored.

Parameters:
Name Type Attributes Description
message String <optional>

Reason the spec is pending.

spyOn(obj, methodName) → {Spy}

Install a spy onto an existing object.

Parameters:
Name Type Description
obj Object

The object upon which to install the Spy.

methodName String

The name of the method to replace with a Spy.

Returns:
Type
Spy

spyOnProperty(obj, propertyName, accessTypeopt) → {Spy}

Install a spy on a property onto an existing object.

Parameters:
Name Type Attributes Default Description
obj Object

The object upon which to install the Spy

propertyName String

The name of the property to replace with a Spy.

accessType String <optional>
get

The access type (get|set) of the property to Spy on.

Returns:
Type
Spy

xdescribe(description, specDefinitions)

A temporarily disabled describe

Specs within an xdescribe will be marked pending and not executed

Parameters:
Name Type Description
description String

Textual description of the group

specDefinitions function

Function for Jasmine to invoke that will define inner suites a specs

xit(description, testFunctionopt)

A temporarily disabled it

The spec will report as pending and will not be executed.

Parameters:
Name Type Attributes Description
description String

Textual description of what this spec is checking.

testFunction function <optional>

Function that contains the code of your test. Will not be executed.

© 2008–2017 Pivotal Labs
Licensed under the MIT License.
https://jasmine.github.io/api/2.7/global.html