Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface BrowserMocha

Hierarchy

Index

Type aliases

AsyncFunc

AsyncFunc: function

Async callback function used for tests and hooks.

Type declaration

Done

Done: function

Type declaration

    • (err?: any): void
    • Parameters

      • Optional err: any

      Returns void

Func

Func: function

Callback function used for tests and hooks.

Type declaration

IStats

IStats: Stats
deprecated

use Mocha.Stats instead.

Interface

Interface: keyof InterfaceContributions

Reporter

Reporter: keyof ReporterContributions

TestInterface

TestInterface: function

Type declaration

    • Parameters

      Returns void

Constructors

constructor

Properties

after

Execute after running tests.

  • Only available when invoked via the mocha CLI.
see

https://mochajs.org/api/global.html#after

afterEach

afterEach: HookFunction

Execute after each test case.

  • Only available when invoked via the mocha CLI.
see

https://mochajs.org/api/global.html#afterEach

before

before: HookFunction

Execute before running tests.

  • Only available when invoked via the mocha CLI.
see

https://mochajs.org/api/global.html#before

beforeEach

beforeEach: HookFunction

Execute before each test case.

  • Only available when invoked via the mocha CLI.
see

https://mochajs.org/api/global.html#beforeEach

describe

describe: SuiteFunction

Describe a "suite" containing nested suites and tests.

  • Only available when invoked via the mocha CLI.

files

files: string[]

it

Describes a test case.

  • Only available when invoked via the mocha CLI.

options

suite

Describe a "suite" containing nested suites and tests.

  • Only available when invoked via the mocha CLI.

suiteSetup

suiteSetup: HookFunction

Execute before running tests.

  • Only available when invoked via the mocha CLI.
see

https://mochajs.org/api/global.html#before

suiteTeardown

suiteTeardown: HookFunction

Execute after running tests.

  • Only available when invoked via the mocha CLI.
see

https://mochajs.org/api/global.html#after

teardown

teardown: HookFunction

Execute after each test case.

  • Only available when invoked via the mocha CLI.
see

https://mochajs.org/api/global.html#afterEach

test

Describes a test case.

  • Only available when invoked via the mocha CLI.

xit

Describes a pending test case.

  • Only available when invoked via the mocha CLI.

Methods

addFile

  • addFile(file: string): this

allowUncaught

  • allowUncaught(): boolean

asyncOnly

  • asyncOnly(): this

bail

  • bail(bail?: undefined | false | true): this
  • Enable or disable bailing on the first failure.

    see

    https://mochajs.org/api/mocha#bail

    Parameters

    • Optional bail: undefined | false | true

    Returns this

checkLeaks

  • checkLeaks(): this

delay

  • delay(): boolean

enableTimeouts

  • enableTimeouts(enabled?: undefined | false | true): this

fgrep

  • fgrep(str: string): this

forbidOnly

  • forbidOnly(): boolean

forbidPending

  • forbidPending(): boolean

fullTrace

  • fullTrace(): this

globals

  • globals(globals: string | ReadonlyArray<string>): this

grep

  • grep(re: string | RegExp): this

growl

  • growl(): this

hideDiff

  • hideDiff(hideDiff: boolean): this

ignoreLeaks

  • ignoreLeaks(ignore: boolean): this

invert

  • invert(): this

Protected loadFiles

  • loadFiles(fn?: undefined | function): void

noHighlighting

  • noHighlighting(): this

reporter

  • reporter(reporter: Reporter, reporterOptions?: any): this
  • reporter(reporter?: string | ReporterConstructor, reporterOptions?: any): this

retries

  • retries(n: number): this

run

  • run(fn?: undefined | function): Runner
  • run(): void
  • Run tests and invoke fn() when complete.

    Note that run relies on Node's require to execute the test interface functions and will be subject to the cache - if the files are already in the require cache, they will effectively be skipped. Therefore, to run tests multiple times or to run tests in files that are already in the require cache, make sure to clear them from the cache first in whichever manner best suits your needs.

    see

    https://mochajs.org/api/mocha#run

    Parameters

    • Optional fn: undefined | function

    Returns Runner

  • Triggers root suite execution.

    • Only available if flag --delay is passed into Mocha.
    • Only available when invoked via the mocha CLI.
    see

    https://mochajs.org/api/global.html#runWithSuite

    Returns void

setup

  • Setup mocha with the given settings options.

    • Only supported in the browser.

    Parameters

    Returns this

slow

  • slow(slow: string | number): this

throwError

  • throwError(err: any): never
  • Function to allow assertion libraries to throw errors directly into mocha. This is useful when running tests in a browser because window.onerror will only receive the 'message' attribute of the Error.

    • Only supported in the browser.

    Parameters

    • err: any

    Returns never

timeout

  • timeout(timeout: string | number): this

ui

  • ui(name: Interface): this
  • ui(name?: undefined | string): this
  • Set test UI to one of the built-in test interfaces.

    see

    https://mochajs.org/api/mocha#ui

    Parameters

    Returns this

  • Set test UI to one of the built-in test interfaces or loads a test interface from a module path. Defaults to "bdd".

    see

    https://mochajs.org/api/mocha#ui

    Parameters

    • Optional name: undefined | string

    Returns this

useColors

  • useColors(colors: boolean): this

useInlineDiffs

  • useInlineDiffs(inlineDiffs: boolean): this

Generated using TypeDoc