// someFunction.ts
export function someFunction(shouldThrow: boolean): void {
if (shouldThrow) {
throw new Error("I am an error!")
}
}
// someFunction.test.ts
import { someFunction } from "./someFunction"
test("should throw an error", () => {
expect(() => someFunction(true)).toThrow("I am an error!")
})
test("should not throw an error", () => {
expect(() => someFunction(false)).not.toThrow()
})