mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
24 lines
591 B
JavaScript
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));
|
|
});
|
|
});
|