Something went wrong. Try again.
Monorepo for the nibling.run platform
Something went wrong. Try again.
1234567891011121314151617181920212223// Derived from Node.js v24.16.0 (MIT; Copyright Node.js contributors, and Joyent, Inc. and// other Node contributors). See LICENSE-node.// Node's ERR_TEST_FAILURE (lib/internal/errors.js): message is `error.message ?? error`// (inspected when not already a string), `.cause` keeps the original thrown value and// `.failureType` tags why (kTestCodeFailure, kHookFailure, kTestTimeoutFailure, ...).import { inspect } from "../inspect";
export interface TestFailureError extends Error { code: "ERR_TEST_FAILURE"; failureType: string; cause: unknown;}
export function testFailure(error: unknown, failureType: string): TestFailureError { const raw = (error as { message?: unknown } | null)?.message ?? error; const msg = typeof raw === "string" ? raw : inspect(raw); const e = new Error(msg) as TestFailureError; e.code = "ERR_TEST_FAILURE"; e.failureType = failureType; e.cause = error; return e;}