Docs (4.0.0)
Tests

test

Adds a test case in the current scope.

test(name: string, f: (test: TestCase) => void | Promise<void>): void

Notes

  • This function must be used within a function passed to describe().
  • Test functions may be async, all promises are awaited automatically.

Parameters

  • name — The name of the test
  • f — The function that defines the test; if this function throws an error, the test fails automatically

Example

// define a simple test:
describe("Math", () => {
  test("One plus one", () => {
    expect(1 + 1).toBe(2);
  });
});

Static Members