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 flaky search scrape test assertions (#3173)
Abimael Martell6a5965a011cb
diff --git a/apps/api/src/__tests__/snips/v2/search.test.ts b/apps/api/src/__tests__/snips/v2/search.test.tsindex cbdfa67f4..b91ab1551 100644--- a/apps/api/src/__tests__/snips/v2/search.test.ts+++ b/apps/api/src/__tests__/snips/v2/search.test.ts@@ -41,7 +41,7 @@ describeIf(TEST_PRODUCTION || HAS_SEARCH || HAS_PROXY)("Search tests", () => {const res = await search({query: "firecrawl.dev",- limit: 2,+ limit: 5,scrapeOptions: {formats: ["markdown"],},@@ -50,9 +50,27 @@ describeIf(TEST_PRODUCTION || HAS_SEARCH || HAS_PROXY)("Search tests", () => {identity,);+ expect(res.web).toBeDefined();+ expect(res.web?.length).toBeGreaterThan(0);++ let markdownCount = 0;+for (const doc of res.web ?? []) {- expect(doc.markdown).toBeDefined();+ if (doc.markdown) {+ markdownCount += 1;+ } else {+ // Search can return URLs that are not consistently scrapeable in test environments,+ // so log the failing entries to make partial scrape failures easier to debug.+ console.warn("Search scrape result missing markdown", {+ url: doc.url,+ error: doc.metadata?.error,+ statusCode: doc.metadata?.statusCode,+ });+ expect(doc.metadata?.error).toBeDefined();+ }}++ expect(markdownCount).toBeGreaterThan(0);},125000,);