Skip to content

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

Merge pull request #989 from RutamBhagat/js-sdk-conditionally-enforce-api-key

Nicolas67c643ad1cff
diff --cc apps/js-sdk/firecrawl/src/__tests__/v1/e2e_withAuth/index.test.ts
index 81b0a523b,60d0b44f9..e5c042096
--- a/apps/js-sdk/firecrawl/src/__tests__/v1/e2e_withAuth/index.test.ts
+++ b/apps/js-sdk/firecrawl/src/__tests__/v1/e2e_withAuth/index.test.ts
@@@ -155,10 -168,21 +168,15 @@@ describe('FirecrawlApp E2E Tests', () =
}, 30000); // 30 seconds timeout
test.concurrent('should throw error for invalid API key on crawl', async () => {
- const invalidApp = new FirecrawlApp({ apiKey: "invalid_api_key", apiUrl: API_URL });
- await expect(invalidApp.crawlUrl('https://roastmywebsite.ai')).rejects.toThrow("Request failed with status code 401");
+ if (API_URL.includes('api.firecrawl.dev')) {
+ const invalidApp = new FirecrawlApp({ apiKey: "invalid_api_key", apiUrl: API_URL });
+ await expect(invalidApp.crawlUrl('https://roastmywebsite.ai')).rejects.toThrow("Request failed with status code 404");
+ } else {
+ const invalidApp = new FirecrawlApp({ apiKey: "invalid_api_key", apiUrl: API_URL });
+ await expect(invalidApp.crawlUrl('https://roastmywebsite.ai')).resolves.not.toThrow();
+ }
});
- test.concurrent('should throw error for blocklisted URL on crawl', async () => {
- const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
- const blocklistedUrl = "https://twitter.com/fake-test";
- await expect(app.crawlUrl(blocklistedUrl)).rejects.toThrow("URL is blocked. Firecrawl currently does not support social media scraping due to policy restrictions.");
- });
-
test.concurrent('should return successful response for crawl and wait for completion', async () => {
const app = new FirecrawlApp({ apiKey: TEST_API_KEY, apiUrl: API_URL });
const response = await app.crawlUrl('https://roastmywebsite.ai', {}, 30) as CrawlStatusResponse;