Docs (4.0.0)
class TestCase method

fail

Fails this test case immediately with the provided error.

fail(error?: Error | string | unknown): void

Notes

  • This method does not throw an error, so control flow continues after calling .fail(...). This may be useful to fail a test from within a callback function rather than the main test function.
  • If the test case has already failed, this method does nothing.

Parameters

  • error — The error to associate with this test case, preferably as an Error instance (to be able to display the JavaScript call stack) but may be any value

Example

describe("My scope", () => {
  test("Failing case", (t) => {
    t.fail(new Error("Oops"))
  });
});

Related