Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

test(sdk): cover an unsuccessful response in the JS method

PhantomInTheWiree36b385de13c
diff --git a/apps/js-sdk/firecrawl/src/__tests__/unit/v2/legal-regulatory.test.ts b/apps/js-sdk/firecrawl/src/__tests__/unit/v2/legal-regulatory.test.ts
index e5088a2ac..f3412b49f 100644
--- a/apps/js-sdk/firecrawl/src/__tests__/unit/v2/legal-regulatory.test.ts
+++ b/apps/js-sdk/firecrawl/src/__tests__/unit/v2/legal-regulatory.test.ts
@@ -64,6 +64,19 @@ describe("legalRegulatorySearch", () => {
expect(http.post).not.toHaveBeenCalled();
});
+ test("throws on an unsuccessful response body", async () => {
+ const http = {
+ post: jest.fn(async () => ({
+ status: 200,
+ data: { success: false, error: "Search failed" },
+ })),
+ } as any;
+
+ await expect(
+ clientWith(http).legalRegulatorySearch("zoning variance"),
+ ).rejects.toThrow("Search failed");
+ });
+
test("normalizes transport errors to SdkError", async () => {
const http = {
post: jest.fn(async () => {