Class: Env

Env

The Jasmine environment.
Note: Do not construct this directly. You can obtain the Env instance by calling jasmine.getEnv.

Since:
  • 2.0.0

Methods

addReporter(reporterToAdd)

Add a custom reporter to the Jasmine environment.

Parameters:
Name Type Description
reporterToAdd Reporter

The reporter to be added.

Since:
  • 2.0.0
See:

allowRespy(allow)

Configures whether Jasmine should allow the same function to be spied on more than once during the execution of a spec. By default, spying on a function that is already a spy will cause an error.

Parameters:
Name Type Description
allow boolean

Whether to allow respying

Since:
  • 2.5.0

clearReporters()

Clear all registered reporters

Since:
  • 2.5.2

configuration() → {Configuration}

Get the current configuration for your jasmine environment

Since:
  • 3.3.0
Returns:
Type
Configuration

configure(configuration)

Configure your jasmine environment

Parameters:
Name Type Description
configuration Configuration
Since:
  • 3.3.0

deprecated(deprecation, optionsopt)

Causes a deprecation warning to be logged to the console and reported to reporters.

The optional second parameter is an object that can have either of the following properties:

omitStackTrace: Whether to omit the stack trace. Optional. Defaults to false. This option is ignored if the deprecation is an Error. Set this when the stack trace will not contain anything that helps the user find the source of the deprecation.

ignoreRunnable: Whether to log the deprecation on the root suite, ignoring the spec or suite that's running when it happens. Optional. Defaults to false.

Parameters:
Name Type Attributes Description
deprecation String | Error

The deprecation message

options Object <optional>

Optional extra options, as described above

Since:
  • 2.99

execute(runablesToRunopt, onCompleteopt) → {Promise.<JasmineDoneInfo>}

Executes the specs.

If called with no parameters or with a falsy value as the first parameter, all specs will be executed except those that are excluded by a spec filter or other mechanism. If the first parameter is a list of spec/suite IDs, only those specs/suites will be run.

Both parameters are optional, but a completion callback is only valid as the second parameter. To specify a completion callback but not a list of specs/suites to run, pass null or undefined as the first parameter. The completion callback is supported for backward compatibility. In most cases it will be more convenient to use the returned promise instead.

execute should not be called more than once unless the env has been configured with {autoCleanClosures: false}.

execute returns a promise. The promise will be resolved to the same overall result that's passed to a reporter's jasmineDone method, even if the suite did not pass. To determine whether the suite passed, check the value that the promise resolves to or use a Reporter.

Parameters:
Name Type Attributes Description
runablesToRun Array.<string> <optional>

IDs of suites and/or specs to run

onComplete function <optional>

Function that will be called after all specs have run

Since:
  • 2.0.0
Returns:
Type
Promise.<JasmineDoneInfo>

provideFallbackReporter(reporterToAdd)

Provide a fallback reporter if no other reporters have been specified.

Parameters:
Name Type Description
reporterToAdd Reporter

The reporter

Since:
  • 2.5.0
See:

setSpecProperty(key, value)

Sets a user-defined property that will be provided to reporters as part of the properties field of SpecResult

Parameters:
Name Type Description
key String

The name of the property

value *

The value of the property

Since:
  • 3.6.0

setSuiteProperty(key, value)

Sets a user-defined property that will be provided to reporters as part of the properties field of SuiteResult

Parameters:
Name Type Description
key String

The name of the property

value *

The value of the property

Since:
  • 3.6.0

topSuite() → {Suite}

Provides the root suite, through which all suites and specs can be accessed.

Since:
  • 2.0.0
Returns:

the root suite

Type
Suite