Suite

Mocha. Suite

new Suite(title, parentContext)

Source:

Initialize a new Suite with the given title and ctx. Derived from EventEmitter

Parameters:
NameTypeDescription
titlestring
parentContextContext

Methods

(static) Suite#fullTitle() → {string}

Source:

Return the full title generated by recursively concatenating the parent's
full title.

Returns:
Type
string

(static) Suite#titlePath() → {string}

Source:

Return the title path generated by recursively concatenating the parent's
title path.

Returns:
Type
string

(static) Suite#total() → {number}

Source:

Return the total number of tests.

Returns:
Type
number

addSuite(suite) → {Suite}

Source:

Add a test suite.

Parameters:
NameTypeDescription
suiteSuite
Returns:

for chaining

Type
Suite

addTest(test) → {Suite}

Source:

Add a test to this suite.

Parameters:
NameTypeDescription
testTest
Returns:

for chaining

Type
Suite

afterAll(title, fn) → {Suite}

Source:

Run fn(test[, done]) after running tests.

Parameters:
NameTypeDescription
titlestring
fnfunction
Returns:

for chaining

Type
Suite

afterEach(title, fn) → {Suite}

Source:

Run fn(test[, done]) after each test case.

Parameters:
NameTypeDescription
titlestring
fnfunction
Returns:

for chaining

Type
Suite

bail(bail) → {Suite|number}

Source:

Set or get whether to bail after first error.

Parameters:
NameTypeDescription
bailboolean
Returns:

for chaining

Type
Suite | number

beforeAll(title, fn) → {Suite}

Source:

Run fn(test[, done]) before running tests.

Parameters:
NameTypeDescription
titlestring
fnfunction
Returns:

for chaining

Type
Suite

beforeEach(title, fn) → {Suite}

Source:

Run fn(test[, done]) before each test case.

Parameters:
NameTypeDescription
titlestring
fnfunction
Returns:

for chaining

Type
Suite

clone() → {Suite}

Source:

Return a clone of this Suite.

Returns:
Type
Suite

eachTest(fn) → {Suite}

Source:

Iterates through each suite recursively to find all tests. Applies a
function in the format fn(test).

Parameters:
NameTypeDescription
fnfunction
Returns:
Type
Suite

enableTimeouts(enabled) → {Suite|boolean}

Source:

Set or get timeout to enabled.

Parameters:
NameTypeDescription
enabledboolean
Returns:

self or enabled

Type
Suite | boolean

isPending()

Source:

Check if this suite or its parent suite is marked as pending.

retries(n) → {Suite|number}

Source:

Set or get number of times to retry a failed test.

Parameters:
NameTypeDescription
nnumber | string
Returns:

for chaining

Type
Suite | number

run()

Source:

This will run the root suite if we happen to be running in delayed mode.

slow(ms) → {Suite|number}

Source:

Set or get slow ms or short-hand such as "2s".

Parameters:
NameTypeDescription
msnumber | string
Returns:

for chaining

Type
Suite | number

timeout(ms) → {Suite|number}

Source:

Set or get timeout ms or short-hand such as "2s".

Parameters:
NameTypeDescription
msnumber | string
Returns:

for chaining

Type
Suite | number