Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Suite

A test Suite is a test environment in which all tests, groups, and hooks are run together.

Hierarchy

  • _Suite
    • Suite

Index

Constructors

constructor

Properties

after

after: (fn: () => void | Promise<void>) => Suite = ...

Alias for afterAll method

Type declaration

    • (fn: () => void | Promise<void>): Suite
    • Adds a function to be called after all tests have run.

      Parameters

      • fn: () => void | Promise<void>
          • (): void | Promise<void>
          • Returns void | Promise<void>

      Returns Suite

before

before: (fn: () => void | Promise<void>) => Suite = ...

Alias for beforeAll method

Type declaration

    • (fn: () => void | Promise<void>): Suite
    • Adds a function to be called before all tests are run.

      Parameters

      • fn: () => void | Promise<void>
          • (): void | Promise<void>
          • Returns void | Promise<void>

      Returns Suite

describe

describe: (name: string, fn: (suite: _Suite) => void) => Suite = ...

Alias for group method

Type declaration

    • (name: string, fn: (suite: _Suite) => void): Suite
    • Groups provides a way to keep tests easier to read and organized. A group is a test environment in which all tests, sub-groups, and hooks are run together within a shared context.

      Parameters

      • name: string

        Unique, human-readable name for the group.

      • fn: (suite: _Suite) => void

        The initialization function.

          • (suite: _Suite): void
          • Parameters

            • suite: _Suite

            Returns void

      Returns Suite

Readonly end

end: Promise<SuiteEnd> = ...

The public interface to the deferred result object that resolves once the test suite has been run.

hooks

hooks: Hooks

The hooks namespace, for easier access via destructuring.

it

it: { (t: TestDefinition): Suite; (name: string, fn: () => void | Promise<void>): Suite } = ...

Alias for test method

Type declaration

    • Register a test which will be run when the suite is run. fn can be async if required.

      example
      import  { Suite, assert } from "@nullify/testing";
      const { test } = new Suite("test")
      
      test({
        name: "example test",
        fn(): void {
          assert.strictEquals("world", "world");
        },
      });
      
      test({
        name: "example ignored test",
        ignore: true, // Could be conditional
        fn(): void {
          // This test is ignored if ignore is true
        },
      });
      
      test({
        name: "example async test",
        async fn() {
          const data = await Promise.resolve("hello world");
          assert.strictEquals(data, "Hello world");
        }
      });
      

      Parameters

      Returns Suite

    • Register a test which will be run when the suite is run. fn can be async if required.

      example
      import  { Suite, assert } from "@nullify/testing";
      const { test } = new Suite("test")
      
      test("My test description", (): void => {
        assert.strictEquals("hello", "hello");
      });
      
      test("My async test description", async (): Promise<void> => {
          const data = await Promise.resolve("hello world");
          assert.strictEquals(data, "Hello world");
      });
      

      Parameters

      • name: string
      • fn: () => void | Promise<void>
          • (): void | Promise<void>
          • Returns void | Promise<void>

      Returns Suite

Readonly name

name: string

options

options: RunOptions = {}

The options to control test suite runs.

Methods

afterAll

  • afterAll(fn: () => void | Promise<void>): Suite
  • Adds a function to be called after all tests have run.

    Parameters

    • fn: () => void | Promise<void>
        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns Suite

afterEach

  • afterEach(fn: () => void | Promise<void>): Suite
  • Adds a function to be called after each test runs.

    Parameters

    • fn: () => void | Promise<void>
        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns Suite

beforeAll

  • beforeAll(fn: () => void | Promise<void>): Suite
  • Adds a function to be called before all tests are run.

    Parameters

    • fn: () => void | Promise<void>
        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns Suite

beforeEach

  • beforeEach(fn: () => void | Promise<void>): Suite
  • Adds a function to be called before each test runs.

    Parameters

    • fn: () => void | Promise<void>
        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns Suite

group

  • group(name: string, fn: (suite: _Suite) => void): Suite
  • Groups provides a way to keep tests easier to read and organized. A group is a test environment in which all tests, sub-groups, and hooks are run together within a shared context.

    Parameters

    • name: string

      Unique, human-readable name for the group.

    • fn: (suite: _Suite) => void

      The initialization function.

        • (suite: _Suite): void
        • Parameters

          • suite: _Suite

          Returns void

    Returns Suite

reset

  • Reset the test suite by clearing out internal cache, registry, and stack.

    Returns Suite

run

  • Manually run the test suite. This is generally not needed, as the test suite should run automatically in most cases (unless autoRun is set to false).

    Parameters

    • opts: RunOptions = {}

      The options to control test suite run.

    Returns Promise<SuiteEnd>

test

  • Register a test which will be run when the suite is run. fn can be async if required.

    example
    import  { Suite, assert } from "@nullify/testing";
    const { test } = new Suite("test")
    
    test({
      name: "example test",
      fn(): void {
        assert.strictEquals("world", "world");
      },
    });
    
    test({
      name: "example ignored test",
      ignore: true, // Could be conditional
      fn(): void {
        // This test is ignored if ignore is true
      },
    });
    
    test({
      name: "example async test",
      async fn() {
        const data = await Promise.resolve("hello world");
        assert.strictEquals(data, "Hello world");
      }
    });
    

    Parameters

    Returns Suite

  • Register a test which will be run when the suite is run. fn can be async if required.

    example
    import  { Suite, assert } from "@nullify/testing";
    const { test } = new Suite("test")
    
    test("My test description", (): void => {
      assert.strictEquals("hello", "hello");
    });
    
    test("My async test description", async (): Promise<void> => {
        const data = await Promise.resolve("hello world");
        assert.strictEquals(data, "Hello world");
    });
    

    Parameters

    • name: string
    • fn: () => void | Promise<void>
        • (): void | Promise<void>
        • Returns void | Promise<void>

    Returns Suite

Static create

  • Create a new test suite.

    Parameters

    • name: string

      Unique, human-readable name for the suite.

    Returns Suite

  • Create a new test suite.

    Parameters

    • Optional opts: SuiteOptions

      The options to control test suite initialization and runs.

    Returns Suite

Generated using TypeDoc