Files
bun.sh/test/regression/issue/12650.test.js
2024-09-03 21:32:52 -07:00

24 lines
591 B
JavaScript

import { describe, expect, it } from "bun:test";
// Custom class for testing
class CustomException extends Error {
constructor(message) {
super(message);
this.name = "CustomException";
}
}
describe("Test expect.toThrow(expect.any())", () => {
it("should throw an error", () => {
expect(() => {
throw new CustomException("Custom error message");
}).toThrow(expect.any(Error));
});
it("should throw a CustomException", () => {
expect(() => {
throw new CustomException("Custom error message");
}).toThrow(expect.any(CustomException));
});
});