Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
fix(js-sdk/tests/e2e): use IDMUX for reliability, re-enable usage tests
Gergő Móricz0c9c2d9301b3
diff --git a/.github/workflows/test-js-sdk.yml b/.github/workflows/test-js-sdk.ymlindex 23cc2de23..ea925b4e6 100644--- a/.github/workflows/test-js-sdk.yml+++ b/.github/workflows/test-js-sdk.yml@@ -8,7 +8,7 @@ on:- apps/js-sdk/firecrawl/**env:- TEST_API_KEY: ${{ secrets.TEST_API_KEY }}+ IDMUX_URL: ${{ secrets.IDMUX_URL }}jobs:test:diff --git a/apps/js-sdk/firecrawl/src/__tests__/e2e/v2/scrape.test.ts b/apps/js-sdk/firecrawl/src/__tests__/e2e/v2/scrape.test.tsindex 53c4f12ae..e44663768 100644--- a/apps/js-sdk/firecrawl/src/__tests__/e2e/v2/scrape.test.ts+++ b/apps/js-sdk/firecrawl/src/__tests__/e2e/v2/scrape.test.ts@@ -128,9 +128,9 @@ describe("v2.scrape e2e", () => {});expect(doc.images).toBeTruthy();expect(Array.isArray(doc.images)).toBe(true);- expect(doc.images.length).toBeGreaterThan(0);+ expect(doc.images?.length).toBeGreaterThan(0);// Should find firecrawl logo/branding images- expect(doc.images.some(img => img.includes("firecrawl") || img.includes("logo"))).toBe(true);+ expect(doc.images?.some(img => img.includes("firecrawl") || img.includes("logo"))).toBe(true);}, 60_000);test("images format: works with multiple formats", async () => {@@ -142,7 +142,7 @@ describe("v2.scrape e2e", () => {expect(doc.links).toBeTruthy();expect(doc.images).toBeTruthy();expect(Array.isArray(doc.images)).toBe(true);- expect(doc.images.length).toBeGreaterThan(0);+ expect(doc.images?.length).toBeGreaterThan(0);// Images should find things not available in links formatconst imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp', '.svg', '.ico'];@@ -151,7 +151,7 @@ describe("v2.scrape e2e", () => {) || [];// Should discover additional images beyond those with obvious extensions- expect(doc.images.length).toBeGreaterThanOrEqual(linkImages.length);+ expect(doc.images?.length).toBeGreaterThanOrEqual(linkImages.length);}, 60_000);test("invalid url should throw", async () => {diff --git a/apps/js-sdk/firecrawl/src/__tests__/e2e/v2/search.test.ts b/apps/js-sdk/firecrawl/src/__tests__/e2e/v2/search.test.tsindex 3d8ecd4d1..b1b31ffd2 100644--- a/apps/js-sdk/firecrawl/src/__tests__/e2e/v2/search.test.ts+++ b/apps/js-sdk/firecrawl/src/__tests__/e2e/v2/search.test.ts@@ -2,7 +2,7 @@* E2E tests for v2 search (translated from Python tests)*/import Firecrawl from "../../../index";-import type { Document, SearchResult } from "../../../index";+import type { Document, SearchResultWeb, SearchResultNews, SearchResultImages } from "../../../index";import { config } from "dotenv";import { getIdentity, getApiUrl } from "./utils/idmux";import { describe, test, expect, beforeAll } from "@jest/globals";@@ -28,7 +28,7 @@ function collectTexts(entries: any[] | undefined): string[] {return texts;}-function isDocument(entry: Document | SearchResult | undefined | null): entry is Document {+function isDocument(entry: Document | SearchResultWeb | SearchResultNews | SearchResultImages | undefined | null): entry is Document {if (!entry) return false;const d = entry as Document;return (@@ -86,10 +86,10 @@ describe("v2.search e2e", () => {expect(results.images == null).toBe(true);const webTitles = (results.web || [])- .filter((r): r is SearchResult => !isDocument(r))+ .filter((r): r is SearchResultWeb => !isDocument(r)).map(r => (r.title || "").toString().toLowerCase());const webDescriptions = (results.web || [])- .filter((r): r is SearchResult => !isDocument(r))+ .filter((r): r is SearchResultWeb => !isDocument(r)).map(r => (r.description || "").toString().toLowerCase());const allWebText = (webTitles.concat(webDescriptions)).join(" ");expect(allWebText.includes("firecrawl")).toBe(true);@@ -183,7 +183,7 @@ describe("v2.search e2e", () => {expect(Boolean(result.markdown) || Boolean(result.html)).toBe(true);} else {expect(typeof result.url).toBe("string");- expect(result.url.startsWith("http")).toBe(true);+ expect(result.url?.startsWith("http")).toBe(true);}}}@@ -193,7 +193,7 @@ describe("v2.search e2e", () => {for (const result of results.images || []) {if (!isDocument(result)) {expect(typeof result.url).toBe("string");- expect(result.url.startsWith("http")).toBe(true);+ expect(result.url?.startsWith("http")).toBe(true);}}}, 120_000);diff --git a/apps/js-sdk/firecrawl/src/__tests__/e2e/v2/usage.test.ts b/apps/js-sdk/firecrawl/src/__tests__/e2e/v2/usage.test.tsindex 8cbb61752..e11d7527e 100644--- a/apps/js-sdk/firecrawl/src/__tests__/e2e/v2/usage.test.ts+++ b/apps/js-sdk/firecrawl/src/__tests__/e2e/v2/usage.test.ts@@ -23,16 +23,15 @@ describe("v2.usage e2e", () => {expect(typeof resp.maxConcurrency).toBe("number");}, 60_000);- // NOTE: Disabled, broken on central team due to overflow- // test("get_credit_usage", async () => {- // const resp = await client.getCreditUsage();- // expect(typeof resp.remainingCredits).toBe("number");- // }, 60_000);-- // test("get_token_usage", async () => {- // const resp = await client.getTokenUsage();- // expect(typeof resp.remainingTokens).toBe("number");- // }, 60_000);+ test("get_credit_usage", async () => {+ const resp = await client.getCreditUsage();+ expect(typeof resp.remainingCredits).toBe("number");+ }, 60_000);++ test("get_token_usage", async () => {+ const resp = await client.getTokenUsage();+ expect(typeof resp.remainingTokens).toBe("number");+ }, 60_000);test("get_queue_status", async () => {const resp = await client.getQueueStatus();