Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

  • Parameters

    Returns Mocha

Properties

Private _growl

_growl: any

Private _reporter

_reporter: any

Private _ui

_ui: any

files

files: string[]

globalSetup

globalSetup: HookFunction

Configures one or more global setup fixtures. If given no parameters, unsets any previously-set fixtures.

see

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

globalTeardown

globalTeardown: HookFunction

Configures one or more global teardown fixtures. If given no parameters, unsets any previously-set fixtures.

see

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

options

suite

suite: Suite

Methods

addFile

  • addFile(file: string): Mocha

allowUncaught

  • allowUncaught(): boolean

asyncOnly

bail

  • bail(bail?: boolean): Mocha

checkLeaks

cleanReferencesAfterRun

  • cleanReferencesAfterRun(clean?: boolean): Mocha
  • Enables or disables whether or not to dispose after each test run. Disable this to ensure you can run the test suite multiple times. If disabled, be sure to dispose mocha when you're done to prevent memory leaks.

    see

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

    Parameters

    • Optional clean: boolean

    Returns Mocha

delay

  • delay(): boolean

dispose

  • dispose(): void
  • Manually dispose this mocha instance. Mark this instance as disposed and unable to run more tests. It also removes function references to tests functions and hooks, so variables trapped in closures can be cleaned by the garbage collector.

    see

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

    Returns void

dryRun

  • dryRun(dryRun?: boolean): Mocha
  • Whether to activate dry-run mode.

    Parameters

    • Optional dryRun: boolean

      Whether to activate dry-run mode. Defaults to true.

    Returns Mocha

enableGlobalSetup

  • enableGlobalSetup(enabled: boolean): Mocha

enableGlobalTeardown

  • enableGlobalTeardown(enabled: boolean): Mocha

fgrep

  • fgrep(str: string): Mocha

forbidOnly

  • forbidOnly(): boolean

forbidPending

  • forbidPending(): boolean

fullTrace

globals

  • globals(globals: string | readonly string[]): Mocha

grep

growl

hasGlobalSetupFixtures

  • hasGlobalSetupFixtures(): boolean

hasGlobalTeardownFixtures

  • hasGlobalTeardownFixtures(): boolean

invert

Protected loadFiles

  • loadFiles(fn?: () => void): void

loadFilesAsync

noHighlighting

  • noHighlighting(): Mocha

parallelMode

  • parallelMode(enabled?: boolean): Mocha
  • Toggles parallel mode.

    Must be run before calling run. Changes the Runner class to use; also enables lazy file loading if not already done so.

    see

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

    Parameters

    • Optional enabled: boolean

    Returns Mocha

reporter

retries

  • retries(n: number): Mocha

rootHooks

run

  • run(fn?: (failures: number) => void): Runner
  • 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: (failures: number) => void
        • (failures: number): void
        • Parameters

          • failures: number

          Returns void

    Returns Runner

slow

  • slow(slow: string | number): Mocha

timeout

  • timeout(timeout: string | number): Mocha

ui

unloadFiles

  • Unloads files from Node's require cache.

    This allows required files to be "freshly" reloaded, providing the ability to reuse a Mocha instance programmatically. Note: does not clear ESM module files from the cache

    Returns Mocha