unreachable

Bun

Symbol

Expect.unreachable

unreachable(msg?: string | Error): never

Throw an error if this function is called.

@param msg

Optional message to display if the test fails

@returns

never

Example

import { expect, test } from "bun:test";

test("!!abc!! is not a module", () => {
 try {
    require("!!abc!!");
    expect.unreachable();
 } catch(e) {
    expect(e.name).not.toBe("UnreachableError");
 }
});

Referenced types

interface Error