Options
All
  • Public
  • Public/Protected
  • All
Menu

Creates a test closure

Hierarchy

  • It

Callable

  • __call(name: string, fn?: ProvidesCallback, timeout?: undefined | number): void
  • Creates a test closure.

    Parameters

    • name: string

      The name of your test

    • Optional fn: ProvidesCallback

      The function for your test

    • Optional timeout: undefined | number

      The timeout for an async function test

    Returns void

Index

Properties

concurrent

concurrent: It

Experimental and should be avoided.

each

each: Each

Use if you keep duplicating the same test with different data. .each allows you to write the test once and pass data in.

.each is available with two APIs:

1 test.each(table)(name, fn)

  • table: Array of Arrays with the arguments that are passed into the test fn for each row.
  • name: String the title of the test block.
  • fn: Function the test to be ran, this is the function that will receive the parameters in each row as function arguments.

2 test.each table(name, fn)

  • table: Tagged Template Literal
  • name: String the title of the test, use $variable to inject test data into the test title from the tagged template expressions.
  • fn: Function the test to be ran, this is the function that will receive the test data object..
example

// API 1 test.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])( '.add(%i, %i)', (a, b, expected) => { expect(a + b).toBe(expected); }, );

// API 2 test.eacha | b | expected ${1} | ${1} | ${2} ${1} | ${2} | ${3} ${2} | ${1} | ${3}('returns $expected when $a is added $b', ({a, b, expected}) => { expect(a + b).toBe(expected); });

only

only: It

Only runs this test in the current file.

skip

skip: It

Skips running this test in the current file.

todo

todo: It

Sketch out which tests to write in the future.

Generated using TypeDoc